Jump to content

Foreign Keys


23.12.2012

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...