This is a discussion on "syntax error..." within the Databases section. This forum, and the thread "syntax error... are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
syntax error...
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
syntax error...
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... |
|
|
|
||||
|
Re: syntax error...
IIRC, you can't auto-increment a column other than the primary key. I could be wrong but that's my recollection.
Edit: Sorry, I looked in my book and the syntax for your primary key assignment looks fine. Perhaps the mistake is that you aren't assigning a table name Last edited by masonbarge; Feb 6th, 2007 at 12:39. |
![]() |
| Tags |
| mysql, syntax error |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] error in SQL syntax but where it all looks fine to me | Andrew1986 | Databases | 3 | Nov 28th, 2007 01:21 |
| Syntax error with Ajax file reading | Paramiliar | JavaScript Forum | 0 | Aug 12th, 2007 16:48 |
| Annoying little syntax error | adeking | Web Page Design | 4 | Aug 9th, 2006 13:50 |
| error in SQL syntax | Drgreenfingers | Databases | 10 | Jan 30th, 2006 02:00 |
| syntax error: unexpected T_BOOLEAN_AND... | jswebdev | PHP Forum | 4 | Jan 28th, 2006 07:29 |