Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 INSERT record in relation to another table

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-21 : 08:25:47
boon writes "INSERT record in relation to another table >>
As in I want to insert record in table A, but the inserted record is actually multiple rows from table B

Table A:
roomID ID(from tableB)
room1 1
room1 2
room1 3
room1 4
room1 5
room2 1
room2 2
... ...


Table B:
ID row seatnumber
1 1 1
2 1 2
3 1 3
4 2 1
5 2 2
... ... ...

--------------------
I want to use a SINGLE sql statement to insert a new room with the IDs from table B
How do I do that?
thanks Gurus"

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2002-06-21 : 10:25:16
Lookup CROSS JOIN in BOLs for more information.

INSERT TableA
SELECT TableB.ID, tb.ID2 from TableB
CROSS JOIN (select ID as ID2 from TableB) as tb
Go to Top of Page
   

- Advertisement -