syntax error...

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 3rd, 2007, 16:09
Up'n'Coming Member
Join Date: Sep 2005
Location: athens
Age: 25
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
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...
Reply With Quote

  #2 (permalink)  
Old Feb 4th, 2007, 03:50
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: syntax error...

I never was very good at MySQL syntax. If you have access to PhpMyAdmin, perhaps you could manually create it there and compare the query it executes to yours? Sorry I could be of more help.
Reply With Quote
  #3 (permalink)  
Old Feb 4th, 2007, 14:48
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
Reply

Tags
mysql, syntax error

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 19:51.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43