Home:ALL Converter>Creating a foreign key in MySQL

Creating a foreign key in MySQL

Ask Time:2014-02-04T03:37:59         Author:user3151681

Json Formatter

While trying to create two foreign keys at the time of creating a table, I am getting these errors:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'references customer customerid, foreign key productid references product prodc' at line 8

My query:

create table orders(
    orderid varchar(10) primary key,
    productid varchar(10)  ,
    customerid varchar(10) ,
    dateoforder  date,
    dateofdelivery date,
    paid decimal(12,2),

    foreign key  customerid references customer (customerid),
    foreign key productid  references product (prodcode)
);

Author:user3151681,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/21536164/creating-a-foreign-key-in-mysql
yy