homepage Welcome to WebmasterWorld Guest from 54.197.130.16
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
weird syntax error.
ktsirig




msg:3241826
 5:04 pm on Feb 3, 2007 (gmt 0)

Hello all,
I am trying to create a table using the following syntax:

mysql_query ("CREATE TABLE IF NOT EXISTS RETURN (
RETURN_ID INT(12) NOT NULL AUTO_INCREMENT,
RETURN_RENTAL_ID INT(12) NOT NULL,
RETURN_COPY_ID INT(12) NOT NULL,
RETURN_MOVIE_ID INT(12) NOT NULL,
RETURN_DATE DATE NOT NULL,
PRIMARY KEY (RETURN_ID),
CONSTRAINT RETURN_IBFK_1 FOREIGN KEY(RETURN_RENTAL_ID) REFERENCES RENTAL(RENTAL_ID),
CONSTRAINT RETURN_IBFK_2 FOREIGN KEY(RETURN_COPY_ID) REFERENCES COPY(COPY_ID),
CONSTRAINT RETURN_IBFK_3 FOREIGN KEY(RETURN_MOVIE_ID) REFERENCES MOVIE(MOVIE_ID))"
) die(mysql_error());

I get the following error:
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 'RETURN ( RETURN_ID INT(12) NOT NULL AUTO_INCREMENT, RETURN_RENTAL_ID I' at line 1

I am trying for 3 hours now to find what the problem is... I have checked everything, all about the foreign keys I use etc, but nothing seems to work... I can't see what my syntax error is...
Any help is greatly appreciated...

 

eelixduppy




msg:3241838
 5:39 pm on Feb 3, 2007 (gmt 0)

RETURN is a reserved word [dev.mysql.com] in MySQL. You must surround it with the prime symbol to escape it! (`). An example:

...CREATE TABLE IF NOT EXISTS `RETURN`(...

Generally it is not encouraged to use names that are the same as a reserved word. You might want to think about changing the name of the table.

Good luck! :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved