如果我想同时找到一个主密钥并将其用作插入语句上的外国密钥,那么我可以使用下面的查询(见
INSERT INTO test (id, value)
SELECT foobar.id, 20
FROM foobar WHERE name = joe ;
但如果我想插入不止一个外国密钥呢?
INSERT INTO test (id1, id2, id3, value)
SELECT foobar1.id, foobar2.id, foobar3.id, 20
FROM foobar1 WHERE name = joe
FROM foobar2 WHERE name = joe
FROM foobar3 WHERE name = joe ;
谢谢 谢谢