Problem adding a Foreign Key to table

Discussion in 'PHP' started by Horus7, Jul 13, 2007.

  1. #1
    What's the syntax for adding a foreign key in a pre-existing table? I'm using a Mysql database and I don't know what the problem is.
    I've tried this, but it just will not work:

    
    
    ALTER TABLE CRTutorials 
    ADD CONSTRAINT FK_user_ID
    FOREIGN KEY (user_ID) 
    REFERENCES users(user_ID);
    
    Code (markup):
    When it runs the query with no syntax error, nothing happens at all.
    Please, tell me what's wrong.
    Thanks 4 the assistance.
     
    Horus7, Jul 13, 2007 IP