Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    3

    Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    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.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •