如何使用insert和select语句在表中添加外键?

时间:2016-04-06 10:48:46

标签: mysql select insert foreign-keys

我试过这个

INSERT INTO PARENT (FamilyID,userName, email, password)VALUES ((SELECT FamilyID FROM 'FAMILY' WHERE familyName=‘Idiots13’),'abc12','abc12@gmail.com', 'abc123#’);

我收到了这个错误:

#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 ''FAMILY' WHERE familyName=‘Idiots13’), 'deeepak13','deepak13@gmail.com', '' at line 3

请帮助!!

1 个答案:

答案 0 :(得分:1)

您在‘Idiots13’周围使用了错误的引号,您需要使用'代替

同样的问题也出现在'abc123#’的结尾引用中。