简体   繁体   中英

how to add foreign key in a table using insert and select statement?

i have tried this

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

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

please help!!

You used wrong type of quotes around 'Idiots13' , you need to use ' instead of ' and ' .

The same problem is also in the ending quote of 'abc123#' .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM