Foreign key
Posted: Fri Dec 25, 2009 5:55 am
Hi, I have a code to create two tables. And the code does not work. Can you tell me where is wrong. I think that I need to do something with INDEX.
Code: Select all
mysql_query("CREATE TABLE users
(username varchar(15),
PRIMARY KEY (username),
lastname text,
firstname text,
password text)
ENGINE=INNODB;
")
mysql_query("CREATE TABLE textt
(username varchar(15),
textname text,
textbody text,
INDEX (username),
FOREIGN KEY (username) REFERENCES users(username))
ENGINE=INNODB;
")