Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
CREATE TABLE empDetails (
EMP_ID int(11) primary key NOT NULL,
password varchar(10) NOT NULL
);


obove table relation to below table.


CREATE TABLE LEAVE_DETAILS_ADMIN (
EMP_ID int NOT NULL foreign key ,
leaveEarnedCredit float(2),
leaveCasualCredit float(2),
leaveMaternityCredit float(2)
);

I got this Error Second Table
Posted
Updated 24-Feb-12 20:14pm
v2
Comments
Chuck N0rris 25-Feb-12 4:10am    
What's the error message?
And put your SQL script in code-block

You need to tell SQL which table the foreign key refers to:
SQL
EMP_ID int NOT NULL foreign key REFERENCES empDetails,

BTW, the would be a good idea to declare both keys to be the same size - if you explicitly state int(11) for one, your should also use int(11) for the foreign key rather than just int
 
Share this answer
 
First of all INT(11) is INVALID, You can't specify the column length on the data type INT..

CREATE TABLE empDetails (
EMP_ID int primary key NOT NULL,
password varchar(10) NOT NULL
);


CREATE TABLE LEAVE_DETAILS_ADMIN (
EMP_ID int NOT NULL foreign key references empDetails(EMP_ID) ,
leaveEarnedCredit float(2),
leaveCasualCredit float(2),
leaveMaternityCredit float(2)
);


try this, Hop will works fine,....

All the Best:-)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900