Home >Database >Mysql Tutorial >How to Insert Multiple Rows into a Table Using a Subquery in SQL Server?
Inserting Values into a Table Using a Subquery with Multiple Results
Problem:
You have two SQL Server tables, "article" and "prices", and you want to insert entries into the "prices" table based on a specific set of IDs retrieved from the "article" table. However, your query results in an error because the subquery returns more than one value.
Answer:
To successfully insert values when the subquery returns multiple results, you need to modify your query as follows:
insert into prices (group, id, price) select 7, articleId, 1.50 from article where name like 'ABC%';
In this modified query:
The above is the detailed content of How to Insert Multiple Rows into a Table Using a Subquery in SQL Server?. For more information, please follow other related articles on the PHP Chinese website!