I am trying to create an sql file and import it into a data base. I get an error #1064. The MySQL manual provides no meaningful information as to what this means. Can someone tell me what is wrong with my code and maybe what book if any you recommend I learn from? Thanks. CREATE TABLE IF NOT EXISTS `xhtml_table02` ( 'the_id' int(10) unsigned NOT NULL, `filename` blob NOT NULL, PRIMARY KEY (`the_id`) ) TYPE=MyISAM AUTO_INCREMENT=2 ; INSERT INTO `xhtml_table02` (`the_id`, 'filename') VALUES (1, 'ncncncncncncn');
CREATE TABLE IF NOT EXISTS xhtml_table02( the_id int(10) unsigned NOT NULL auto_increment key, filename blob not null) engine=myisam auto_increment=2
I am still getting the same error. Maybe if I post the error message it will be clearer what the problem might be. Error SQL query: INSERT INTO `xhtml_table02` ( `the_id` , `filename` ) VALUES ( 1, `ncncncncncncn` ) ; MySQL said: Documentation #1054 - Unknown column 'ncncncncncncn' in 'field list'
try it as ---- CREATE TABLE IF NOT EXISTS xhtml_table02 ( the_id int(10) unsigned NOT NULL, filename char (40) NOT NULL, PRIMARY KEY (the_id) ) TYPE=MyISAM AUTO_INCREMENT=2 ; -- INSERT INTO xhtml_table02 VALUES ( 1, `ncncncncncncn`) ; I hope it'l work on ur side now
` is only to surround table and column names. Use the apostrophe ' to surround data. So instead of INSERT INTO xhtml_table02 VALUES ( 1, `ncncncncncncn`) ; This is why you are getting Unknown column 'ncncncncncncn' in 'field list' because it thinks that ncncncncncncn is a field when you use ` Use... INSERT INTO xhtml_table02 VALUES ( 1, 'ncncncncncncn') ;
Thanks for all of your help. I plan on replacing (cncncncnc) with html data, thus is why I am using blob instead of char (40) or some other type. Maybe I should have pointed that out in the first place. I will however probably learn something from the rest of your suggestion. It looks like your apostrophe suggestion worked. Thanks a bunch.
Regardless of what the field data type is, you still use an apostrophe to surround it. Apostrophies are for data, ` is for field names.