SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Syntax Error!

    Hello everyone,

    This is a quickie.

    I'm pretty new to SQL, and MySQL.

    I'm currently learning at Google Code University's Introduction to Databases and MySQL (http://code.google.com/edu/tools101/mysql.html).

    I'm following the tutorial via MySQL console, and I keep getting a syntax error when i type this:

    Code:
    create table orders (order_no int not null auto_increment, FK_cust_no int not null, 
    foreign key(FK_cust_no) references customer(cust_no), primary key(order_no));
    Thanks in advance!

  2. #2
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi haopei,

    I was able to execute your query successfully on MySQL 5.1.

    What version of MySQL are you using? And what's the error that you're getting?

    shamzz

  3. #3
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,097
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Does the table "customers" exist and do the two columns "cust_no" have the exact same data type? If the datatypes differ you can't create a foreign key constrain on the two tables.


Bookmarks

Posting Permissions

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