Jump to content

mysql table


anser316

Recommended Posts

The order table does not insert onto my database:

I get this error:

 

Error

SQL query:

 

CREATE TABLE Order1(

 

orderId Int( 5 ) NOT NULL AUTO_INCREMENT ,

customerId Int( 4 ) NOT NULL ,

date date NOT NULL ,

CONSTRAINT Order_OrderId_pk PRIMARY KEY ( OrderId ) ,

CONSTRAINT Order_customerId_fk foriegn KEY ( customerId ) Reference Customer(

customerId

)

)

 

MySQL said: 

 

#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 'foriegn key(customerId) Reference Customer(customerId))' at line 6

 

This is my inserts, the customer table works:

create table Order1(
orderId		Int(5)		not null AUTO_INCREMENT,
customerId	Int(4)		not null,
date		date		not null,
constraint	Order_OrderId_pk primary key (OrderId),
constraint	Order_customerId_fk foriegn key(customerId) Reference Customer(customerId));

create table Customer(
customerId	Int(4)		not null AUTO_INCREMENT,	
firstName	varchar(30)	not null,
surName		varchar(30)	not null,
telephone	varchar(15)	not null,
mobile		varchar(15)	not null,
dOb		Date		not null,
email		varchar(30)	not null,
password	varchar(6)	not null,	
address		varchar(50)	not null,
town		varchar(10)	not null,
county		varchar(10)	not null,
postcode	varchar(10)	not null,
constraint 	Customer_customerId_pk primary key (customerId),
constraint	Customer_email_uk UNIQUE (email));

 

 

Link to comment
https://forums.phpfreaks.com/topic/102930-mysql-table/
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.