Microsoft
Software
Hardware
Network
Question : How to copy rows from a table and put them in same table and joined to two other tables ?
How to copy rows in a table joined to two other tables ?
I three tables
tableA, tableB and tableC,
tableA and tableB is joined Aid-idA and tableB and tableC is joined Bid-idB
I want to copy from TableC the Rows (Cid = 1, Name= Trek1, idB = 1 AND Cid = 2, Name= Trek2, idB = 1 AND Cid = 3, Name= Trek3, idB = 1) joined to tableB Row (Bid = 1, name = scene1, idA = 1) and place them to the tableB Row (Bid =2, Name = Scen2, idA = 1)
How do I do this ?
TableA TableB TableC
Aid Name Bid Name idA Cid Name idB
1 scan1 1 scen1 1 1 Trek1 1
2 scan2 2 scen2 1 2 Trek2 1
3 scan3 3 scen1 2 3 Trek3 1
4 scan4 4 scen1 3 4 Trek1 2
5 scen1 4 5 Trek2 2
6 Trek1 3
7 Trek2 3
8 Trek1 4
9 Trek2 4
10 Trek1 5
11 Trek2 5
Answer : How to copy rows from a table and put them in same table and joined to two other tables ?
insert into TableB
select TableC.Cid,TableC.Name,Tab
leC.idB
from TableC inner join TableB on TableB.bid=TableC.idb
where TableC.Cid in(1,2,3);
Random Solutions
SQL - display the top and bottom date in one result set
Upgrade to Vista, video card not detected
"Declare Function" err - "not allowed as Public members of object modules"
Populating SharePoint Contact List from Active Directory
.Net 2.0 and Mono compatibility?
Running SQL server DTS with condition check
One question about Log4Net & Common.Logging
Installing Office 2003--How to get Clean Install with updates
vpn hangs on verifying username and password
MS SQL FTS Index Population Error