List:General Discussion« Previous MessageNext Message »
From:Adam Nelson Date:November 18 2002 5:03pm
Subject:RE: Insert row in x for every row in y
View as plain text  
You can use

insert group_map (user_id,group_id) select user_id,"6" as any_label from
user



> -----Original Message-----
> From: Zabel, Ian [mailto:IZabel@stripped] 
> Sent: Monday, November 18, 2002 11:35 AM
> To: mysql@stripped
> Subject: Insert row in x for every row in y
> 
> 
> I've having trouble figuring out the SQL to do this.
> 
> I have two tables, user, and group_map, and I want to insert 
> a row into
> group_map for every row in user.
> 
> user
> ------------
> user_id
> 
> 
> group_map
> ------------
> user_id
> group_id
> 
> 
> For each user_id:
> 	insert into group_map ( user_id, group_id ) values ( user_id, 6
> )
> 
> Can I use a select into or something? Or should I just script 
> it outside
> of mysqlclient?
> 
> Ian.
> 
> 
> 

Thread
Insert row in x for every row in yIan Zabel18 Nov
  • RE: Insert row in x for every row in yAdam Nelson18 Nov
    • RE: Insert row in x for every row in yKeith C. Ivey18 Nov
  • re: Insert row in x for every row in yEgor Egorov19 Nov
    • RE: Insert row in x for every row in yKaruna Bhavnani19 Nov