Will the following query insert as many rows as there are rows in the result-set of the subquery? If not, how can I make insert n rows where n is the number of rows in the result set of the subquery?
INSERT INTO A (x, y)
VALUES (@x, SELECT B.z FROM B)
@x=5
No. It’d only ever insert 1 row at most. If you wanted to insert multiple rows, you’d need to something like
Note that there’s no
valuesclause, and the @x has been integrated into theSELECTquery