更新时间:2022-10-23 23:40:04
请查看以下链接,以获取有关" FOREIGN KEY Constraint "的信息.
http://www.w3schools.com/sql/sql_foreignkey.asp
http://msdn.microsoft.com/en-us/library/ms175464.aspx
,这意味着您的表2没有要由表1引用的主键.
首先将主键分配给要加入的辅助表
问候,
Eduard
在参考表中将Consumer_ID更改为主键
hi
i have two tables. when i tried to add a foreign key using this query
alter table tbl_user_login add constraint fkcid foreign key(fk_Consumer_ID) references tbl_Consumer_details(Consumer_ID)
it shows an error:
There are no primary or candidate keys in the referenced table ''tbl_Consumer_details'' that match the referencing column list in the foreign key ''fkcid''.
help me
thanks in advance
Have a look at below links for information on "FOREIGN KEY Constraint".
http://www.w3schools.com/sql/sql_foreignkey.asp
http://msdn.microsoft.com/en-us/library/ms175464.aspx
this means your table 2 doesn''t have a primary key to be referenced by table 1.
Assign a primary key first to the secondary table you are joining
Regards,
Eduard
Change Consumer_ID as Primary Key in the reference table