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 2005 Forums
 Transact-SQL (2005)
 Delete query

Author  Topic 

lucsky8
Posting Yak Master

105 Posts

Posted - 2009-05-05 : 09:20:31
Hi,
it probably easy but i have no idea

I have simple query

select * from tblEleves
inner join tblResultat on tblEleves.intEleveId = tblResultat.intEleveId
where tblEleves.intEcoleId = 1227

All the result are ok but i need to delete evrething that not equal to this query.
I hope i explain my self wright

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-05-05 : 09:24:40
delete from which table ? tblEleves or tblResultat ? or both ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

lucsky8
Posting Yak Master

105 Posts

Posted - 2009-05-05 : 12:08:07
Sorry i had a meeting delete from
tblEleves

Delete from tblEleves if intEleveId is not in tblResultat

Can i use :
DELETE
FROM tblEleves
WHERE tblEleves.intEleveId NOT IN (select intEleveId from tblResultat) and
tblEleves.intEcoleId = 1227


quote:
Originally posted by khtan

delete from which table ? tblEleves or tblResultat ? or both ?


KH
[spoiler]Time is always against us[/spoiler]





Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-05-05 : 13:04:51
don't you want tblEleves.intEcoleId <> 1227 instead ?
Go to Top of Page

lucsky8
Posting Yak Master

105 Posts

Posted - 2009-05-05 : 15:17:15
It ok it work with


DELETE
FROM tblEleves
WHERE tblEleves.intEleveId NOT IN (select intEleveId from tblResultat) and
tblEleves.intEcoleId = 1227


Tks for your help
quote:
Originally posted by sakets_2000

don't you want tblEleves.intEcoleId <> 1227 instead ?


Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-05-05 : 15:35:33
It will work. But going from what you said previously, "but i need to delete evrething that not equal to this query"... just give a thought once more to what you want. Hope it makes sense.
Go to Top of Page
   

- Advertisement -