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.
Author |
Topic |
wormz666
Posting Yak Master
110 Posts |
Posted - 2008-10-23 : 04:09:42
|
how can i delete a record with in the 2 table please help... i have no idea how to delete the 2 records having the the same id................and also insert data with 2 table having the same id.......thank you in advance.... |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-23 : 04:35:53
|
can you illustrate what you want with some data. cant make out what you're asking for? do you mean delete records from 2 tables or delete record with id 2 and then insert it to another table? |
|
|
wormz666
Posting Yak Master
110 Posts |
Posted - 2008-10-23 : 05:57:53
|
what i mean delete from two table which has the same id then insert it into my back up 2 tabletable1id name1 jason2 Chris3 Christiantable2id occupation1 accountant2 engineer 3 government employeei want to delete whos id is 1 then save it into my back up table bactable1,bactable2..... |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-23 : 06:43:42
|
[code]INSERT INTO BackupSELECT id,nameFROM(SELECT id,name,1 AS cat FROM table1UNION ALLSELECT id,name,2 AS cat FROM table2)tGROUP BY id,name HAVING COUNT(cat) >1DELETE t1 FROM table1 t1 INNER JOIN table2 t2 ON t1.id=t2.idDELETE t2 FROM table1 t1 INNER JOIN table2 t2 ON t1.id=t2.id[/code] |
|
|
|
|
|