Skip to content
Advertisement

How would I insert the same row with all the different subquery values at the same time, almost like an iteration over the subquery?

My problem is that I don’t know a simple way of inserting a selection of employees from the employees table directly into the messages table like:

This returns the error: Error Code: 1242. Subquery returns more than 1 row and I’m not sure on how to proceed from here.

Advertisement

Answer

Use insert . . . select:

Note that the values keyword is not needed. I also replaced the double quotes with single quotes, because these are the SQL standard delimiter for strings.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement