If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > SQL syntal error?...IMPOSSIBLE!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-07-04, 23:23
bamacek bamacek is offline
Registered User
 
Join Date: Jul 2004
Posts: 3
SQL syntal error?...IMPOSSIBLE!

Of the 30-something queries I run against the db, the only one that has given me any problems is the following:

Code:
INSERT INTO order (CustomerID, CartID) 
VALUES ('000000000000000014', 'f62c18efc160cfd173ef962dc932fdd2')
(the values of CustomerID and CartID are obviously somewhat dynamic)


Yet when I run the query, I get a syntal error
Reply With Quote
  #2 (permalink)  
Old 07-07-04, 23:56
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
and that syntax error would be .... ?

what are the datatypes of those two columns?

are there any other columns in that table?
are they NULL, or have default values declared?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 07-08-04, 00:42
bamacek bamacek is offline
Registered User
 
Join Date: Jul 2004
Posts: 3
A little more info...

My bad. Here's some more info:

The error I'm getting is: 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 'order (CustomerID, CartID) VALUES ('000000000000000015', '

Datatypes: CustomerID VARCHAR(18) NO; CartID VARCHAR(32)

Neither one of the columns are NULL, nor do they have a default value assigned to them.

The only other column in the table is OrderID, which comes before CustomerID and CartID, in that order.
Reply With Quote
  #4 (permalink)  
Old 07-08-04, 00:53
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
perhaps it is the table name, order, which is a reserved word

try putting the table in backticks... insert into `order`

your best bet would be to rename it
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 07-08-04, 19:53
bamacek bamacek is offline
Registered User
 
Join Date: Jul 2004
Posts: 3
FIXED IT! Thanks r937

Well, r937 was exactly right. After changing the table name from "order" to "orders", the query worked perfectly!

Let this be a lesson to everyone: Don't name any of your tables using a reserved word.

Thanks r937.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On