Sql query help

Discussion in 'MySQL' started by tin2mon, Sep 17, 2010.

  1. #1
    hi all
    i am just a beginner sql programmer and as a matter of fact i don't know why the ff is not working in mysql:

    CREATE TABLE interests (
    int_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    interest VARCHAR(50) NOT NULL,
    contact_id INT NOT NULL,
    CONSTRAINT my_contacts_contact_id_fk,
    FOREIGN KEY (contact_id),
    REFERENCES my_contacts (contact_id)
    );
    i already have a my_contacts table.
     
    tin2mon, Sep 17, 2010 IP
  2. imperialDirectory

    imperialDirectory Peon

    Messages:
    395
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Change it to:

    CONSTRAINT my_contacts_contact_id_fk
    FOREIGN KEY (contact_id)
    REFERENCES my_contacts (contact_id)

    I don't think you need comma between CONSTRAINT ... FOREIGN ... REFERENCES
     
    imperialDirectory, Sep 17, 2010 IP