Reputation: 18579
I want to take the result of this
SELECT * FROM `orgs`
WHERE `slug` = 'foo'
And use it with this
INSERT INTO `projects-permissions`
(`id`, `project`, `org`)
VALUES
(NULL, 'foo', ORG.ID)
Upvotes: 0
Views: 30
Reputation: 2333
INSERT INTO projects-permissions
(id
, project
, org
)
SELECT null, slug, org FROM orgs
WHERE slug
= "foo";
Upvotes: 1
Reputation: 1397
INSERT INTO `projects-permissions`
(`id`, `project`, `org`)
SELECT null, slug, ID FROM `orgs`
WHERE `slug` = 'foo';
Upvotes: 1
Reputation: 204756
INSERT INTO `projects-permissions` (`id`, `project`, `org`)
SELECT NULL, 'foo', ID
FROM `orgs`
WHERE `slug` = 'foo'
or a little shorter
INSERT INTO `projects-permissions` (`project`, `org`)
SELECT slug, ID
FROM `orgs`
WHERE `slug` = 'foo'
Upvotes: 1