Lakshay Jain Lakshay Jain - 8 months ago 81
MySQL Question

Sql Multiple Insert Query

I want to insert a value for in table 1 for all the id in the table 2.
I tried this:-

INSERT INTO Customers (CustomerName, Country) values(
SELECT SupplierName FROM Suppliers,'India');

But it gave 1 result


Yep, that version is supposed to gve you 1 result only because you placed the select into a values() function. What you want is the insert ... select ... syntax:

INSERT INTO Customers (CustomerName, Country)
SELECT SupplierName, 'India' FROM Suppliers;