23.12.2012 Posted February 12, 2010 Share Posted February 12, 2010 Well... I'm trying to use foreign keys in a project, but each of my attempts have failed somehow. So I've got two tables using the InnoDB engine, and within the second one, I want to make contact_id reference id in the first table. I've googled, but none of the things I've found and tried seemed to work. Here's the one I found in the MySQL 5.0 reference and adapted: CREATE TABLE contacts ( id SMALLINT NOT NULL AUTO_INCREMENT, contact_id SMALLINT NOT NULL REFERENCES users(id), ... PRIMARY KEY (id) ); Engine=InnoDB The ... indicates other lines of code. I get a syntax error, and it happens so with all the other variants I tried. Any specific help here? Thanks in advance! Link to comment Share on other sites More sharing options...
justsomeguy Posted February 16, 2010 Share Posted February 16, 2010 Check the manual, there are examples here:http://dev.mysql.com/doc/refman/5.1/en/inn...onstraints.html Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.