|
Title: Error #1054 on INSERT Post by: klitscher 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 Title: Re: Error #1054 on INSERT Post by: VGR 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 Title: Re: Error #1054 on INSERT Post by: klitscher 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...
Powered by SMF 1.1 RC2 |
SMF © 2001-2005, Lewis Media
Joomla Bridge by JoomlaHacks.com |