类似于this问题,但更高级......
我想取这个结果
SELECT * FROM `orgs`
WHERE `slug` = 'fooA'
这个结果
SELECT * FROM `projects`
WHERE `slug` = 'fooB'
并将其用于此
INSERT INTO `things`
(`id`, `project`, `org`, `thingA`, `thingB`)
VALUES
(NULL, project.id, org.id, 'fooC', 'fooD')
答案 0 :(得分:2)
INSERT INTO `things`
(`id`, `project`, `org`, `thingA`, `thingB`)
SELECT NULL, `project`.`id`, `org`.`id`, 'fooC', 'fooD' FROM `projects`,`orgs`
WHERE `slug` = 'fooA' OR `slug` = 'fooB';