I just started learning php and mySQL, if i want to create 2 tables, how do i connect them with a foreign key? In oracle, it is something like below, would any one point out what have to change to make it work in mySQL? phpMyadmin GUI doesn't seem like it needs a foreign key to connect a table. Please explain a bit and thanks very much.

create table customer(
cid INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
name VARCHAR(20));

CREATE TABLE order(
oid INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
o_date VARCHAR(10),
FOREIGN KEY(cid) REFERENCES customers);

try this

foreignkey (oid) references customer(cid)

as part of the 2nd table creation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.