Syntax error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
cardi777
Forum Commoner
Posts: 54
Joined: Sun Mar 29, 2009 4:26 am

Syntax error

Post by cardi777 »

hi everyone

getting a headache, can't work out whats wrong with this syntax! :banghead:

Code: Select all

INSERT INTO import_table ("content_for_import","date_created","date_modified") VALUES ("content here","0000-00-00 00:00:00","0000-00-00 00:00:00") ON duplicate KEY UPDATE "content_for_import"="content here","date_created"="0000-00-00 00:00:00","date_modified"="0000-00-00 00:00:00";

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' ("content_for_import","date_created","date_modified") VALUES ("content here","0000-00-00 0' at line 1
the content_for_import is a normal text column with NULL as the default
the date created is a datetime with NULL as the default
the date modified is a datetime with 0000-00-00 00:00:00 as the default
There is an id with auto increment etc, and all other sql works fine manipulating this table

can anyone see what i am doing wrong here, because i just can't see it :P

cheers,
Doug
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Syntax error

Post by Darhazer »

Try this one:

Code: Select all

INSERT INTO import_table (`content_for_import`,`date_created`,`date_modified`) VALUES ("content here","0000-00-00 00:00:00","0000-00-00 00:00:00") ON duplicate KEY UPDATE `content_for_import`="content here",`date_created`="0000-00-00 00:00:00",`date_modified`="0000-00-00 00:00:00";
cardi777
Forum Commoner
Posts: 54
Joined: Sun Mar 29, 2009 4:26 am

Re: Syntax error

Post by cardi777 »

thanks heaps, ill give that a shot!
cardi777
Forum Commoner
Posts: 54
Joined: Sun Mar 29, 2009 4:26 am

Re: Syntax error

Post by cardi777 »

it worked beautifully. thanks so much
Post Reply