I am having 2 tables first is smsusers(id,fname,lname,userid)
'id' is primary key,
userid
is unique key
address_detail(id,address,type);
Here I want to add userid
of smsusers
as foreign key to address_detail
table.
for that i added a column to address_detail
as user_id
ALTER TABLE address_detail add user_id INT( 20 ) default NULL;
Now I am adding foreign key constraint to table
ALTER TABLE `address_detail` add CONSTRAINT address_detail_fk FOREIGN KEY (user_id)
REFERENCES smsusers ('userid') ON UPDATE CASCADE ON DELETE CASCADE;
This step is showing following error
#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 ''userid') ON
UPDATE CASCADE ON DELETE CASCADE' at line 1