darma teja

darma teja

  • NA
  • 496
  • 337.5k

same ID different rows in sql

Jul 1 2014 5:46 AM
Hi All,

I want to insert 500 rows in the table.

table has ID, groupID,  name, firstname

My data is like this:

I have  groupIDs: 1,2,3

I have 500 rows of name and firstname.

I want to insert these 500 rows of name and firstname for every gorupID

I wrote like this:

insert into table (groupID,  name, firstname)
SELECT 1, 'a', 'b' union all
SELECT 1, 'c', 'd' union all
SELECT 1, 'e', 'f' union all

But it is difficult to write groupID everytime. Is there any solution?

Many thanks,
Darma


Answers (1)