I have three related tables - Users have Groups, and Groups have Items:
Id UserName
1 Joe
2 Fred
Id GroupName UserId
1 TestGr1 1
2 TestGr2 1
Id ItemName GroupId UserId
1 Item1 1 1
2 Item2 1 1
3 Item3 2 1
4 Item4 2 1
I want to give Fred everything that Joe has, i.e. copy all the related data in Groups and Items.
I have copied the Groups:
insert into Groups
select [GroupName], 2
from Groups
where UserId = 1
How do I proceed with items?
UPDATE
Here's what I want in the end:
Id UserName
1 Joe
2 Fred
Id GroupName UserId
1 TestGr1 1
2 TestGr2 1
3 TestGr1 2
4 TestGr2 2
Id ItemName GroupId UserId
1 Item1 1 1
2 Item2 1 1
3 Item3 2 1
4 Item4 2 1
5 Item1 3 2
6 Item2 3 2
7 Item3 4 2
8 Item4 4 2