|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
A quick way to build this query
Hi,
i need to build a query..i know the long way...need a quick way itemid Routeto 1 NB 1 IQ 1 IP 4 NB 4 IP 4 IQ 5 NB 5 JY 6 AB 6 NB 2 NB 3 IS I want only those itemid which had routeto = NB and never had routeto=IQ or IP i.e 5 ,6 , 2 so i dont want 1,4 to ever come in the resultset! Thks in advance |
|
#2
|
||||
|
||||
|
I did a test using your sample data. Here is what worked:
SELECT itemid FROM sometable WHERE itemid NOT IN(SELECT itemid FROM testtbl WHERE routeto in('IQ','IP')) AND routeto in('NB') Does this help? ![]() |
|
#3
|
|||
|
|||
|
i can see this as alternative...
select itemid from tablexxx where routeto = 'NB' and itemid in ( select itemid from tblexxx where routeto NOT IN ('IQ', 'IP') ) Regards Bishnu |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > A quick way to build this query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|