Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

Error #1054 on INSERT
Welcome, Guest. Please login or register.
December 03, 2008, 11:55:15 PM
11306 Posts in 1249 Topics by 499 Members
Latest Member: haulaslemycle
Experts Round Table Network  |  Databases  |  MySQL  |  Error #1054 on INSERT « previous next »
Pages: [1]
Author Topic: Error #1054 on INSERT  (Read 276 times)
klitscher

Offline Offline

Posts: 24


« on: October 13, 2006, 09:46:15 PM »

Hello all,

I'm having a problem inserting a row into a table...here is my SQL statement...

INSERT INTO `surveys` (`session_id`, `ip`, `meaning`, `life`, `christian`, `jesus`, `frequency`, `talkwithfriends`, `samegod`, `samegodwhy`, `heaven`, `heavenwhy`, `parents`, `siblings`, `otherfam`, `friends`, `clergy`, `stranger`, `opinion`, `question`, `drawing`, `email`, `gender`, `age`, `grade`, `state`, `religion`, `timestamp`)
VALUES (`0f26f8a7b8b5b00baa12eac50c2845ff`, `XXX.XXX.XXX.XXX`, `2`, `2`, `2`, `2`, `More than Twice Weekly`, `Often`, `Yes`, `Why or Why Not?`, `Yes`, `What are they like?`, `Never`, `Never`, `Never`, `Never`, `Never`, `Never`, `Extremely Favorable`, `f`, `1`, `xxx@xxxxxx.xxx`, `male`, `10`, `5th or Under`, `AL`, `Atheist`, NOW());

When you INSERT like this...do the columns have to be in the same order they are structurally....ie, col1 on my table is IP, col2 is session_id, etc.?

The specific error I am getting is:
#1054 - Unknown column '0f26f8a7b8b5b00baa12eac50c2845ff' in 'field list'

any help would be much appreciated...
Ken

Logged
VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #1 on: October 14, 2006, 06:32:15 AM »

Hello,

First I think you don't need quotes around column names and non-char values, and even more you specifically shouldb't use backquotes (see SQL standard)

Then, the answer to your question is NO : no, the column names in the parentheses can be in any order and be a subset of the table definition, and this will work as long as all required (say, NOT NULL) columns do receive an acceptable value.

For your specific error, it means that the quotes do mangle the interpreter/parser so much that it fails to read your VALUES clause. Try to remove all unnecessary quotes and not to include a line break in your SQL phrase ;-))

INSERT INTO surveys (session_id,ip,meaning,life,christian,jesus,frequency,talkwithfriends,samegod,samegodwhy,heaven,heavenwhy,parents,siblings,otherfam,friends,clergy,stranger,opinion,question,drawing,email,gender,age,grade,state,religion,timestamp) VALUES ('0f26f8a7b8b5b00baa12eac50c2845ff','XXX.XXX.XXX.XXX',2,2,2,2,'More than Twice Weekly','Often','Yes','Why or Why Not?','Yes','What are they like?','Never','Never','Never','Never','Never','Never','Extremely Favorable','f',1,'xxx@xxxxxx.xxx','male',10,'5th or Under','AL','Atheist',NOW());

please give feedback if the error still arises. regards
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
klitscher

Offline Offline

Posts: 24


« Reply #2 on: October 18, 2006, 08:17:16 PM »

Sorry for the delay...your response did help me out.  I was unaware about the proper use of quotes, as i've pretty much been learning my sql structure from phpMyAdmin...and that's how they did it...regardless, I've got it working now, so thank you very much!

I've got another sql questions, but i'll post a new topic...
Logged
Pages: [1]
« previous next »
    Jump to: