Reputation: 69
I have a simple task to do, sadly I am stuck. I have two tables: Countries
and Continents
.
Countries
has these columns:
CountryID, CountryName, ContinentID.
Continents
has these columns :
ContinentID, ContinentName.
Now, I need to insert particular ContinentId
into Countries.ContinentID
i.e 1. Belgium 1
.
I would like to write a INSERT INTO
query, that will allow me to insert one value of ContinentID
to multiple rows of CountryID
. Is there a way to do that?
Upvotes: 0
Views: 49
Reputation: 2420
I am not sure if I understand your question correctly
you can use SELECT
in your insert statement
example:
INSERT INTO Countries (CountryID)
SELECT ContinentID FROM Continents GROUP BY ContinentName
Upvotes: 0
Reputation: 37367
I think you need update
statement:
update Countries set ContinentID = 1
--values (1,2,3,4,5,6) are just for example
where CountryID in (1,2,3,4,5,6)
Upvotes: 1