haopei — 2010-05-09T23:57:18-04:00 — #1
This is a quickie.
I'm pretty new to SQL, and MySQL.
I'm currently learning at Google Code University's Introduction to Databases and MySQL (http://code.google.com/edu/tools101/mysql.html).
I'm following the tutorial via MySQL console, and I keep getting a syntax error when i type this:
create table orders (order_no int not null auto_increment, FK_cust_no int not null,
foreign key(FK_cust_no) references customer(cust_no), primary key(order_no));
Thanks in advance!
shamzz — 2010-05-10T01:59:38-04:00 — #2
I was able to execute your query successfully on MySQL 5.1.
What version of MySQL are you using? And what's the error that you're getting?
scallioxtx — 2010-05-10T02:54:46-04:00 — #3
Does the table "customers" exist and do the two columns "cust_no" have the exact same data type? If the datatypes differ you can't create a foreign key constrain on the two tables.