I need to insert mutliple tuples into a table using a subquery as one column value and a static value as the second column value. How would I go about doing this?
My SQL knowledge isn't very vast so I was wondering if you guys could clear this up for me.
Here is an invalid query that shows what I'm trying to achieve.
INSERT INTO deleted_messages (message_id, account_id) VALUES ((
SELECT message_id FROM messages
WHERE conversation_id = 23
), 42);
The subquery returns a table with multiple "message_id" values (which is what I want).
The results I'm looking for:
Table: deleted_messages
id | message_id | account_id
-------------------------
1 | 25 | 42
2 | 36 | 42
3 | 94 | 42
Let me know if I need to clarify. Thanks in advance!