Reputation: 14835
This pulls back one row:
SELECT id FROM pin WHERE pinpicsid = '1'
I need the result of that statement to go where this X is:
INSERT INTO user_collection (pinid, username)
VALUES (X, 'ethanwa')
Is there a way to combine these two?
Upvotes: 0
Views: 44
Reputation: 204756
INSERT INTO user_collection (pinid, username)
SELECT id, 'ethanwa'
FROM pin
WHERE pinpicsid = '1'
Upvotes: 1
Reputation: 11806
Use the INSERT INTO SELECT -statement
INSERT INTO user_collection (pinid, username)
SELECT id, 'ethanwa' FROM pin WHERE pinpicsid = '1'
Upvotes: 4