While working with an error that my students surfaced in the
Oracle Database 12c, I blogged about the limit of using a subquery in an
Oracle INSERT statement, and I discovered
something when retesting it in MySQL. It was a different
limitation. I was also surprised when I didn’t find any mention
of it through a Google search, but then I may just not have the
right keywords.
The original test case uses a subquery to create a multiple row
result set for an INSERT statement. Unfortunately, I
discovered that you can’t always embed a UNION or
UNION ALL inside a subquery. At least, you can’t
when you call the subquery inside an INSERT
statement. For example, let’s create a DESTINATION
table and then we’ll try to insert records with a query that …