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
 General SQL Server Forums
 Script Library
 alternative to subselect query

Author  Topic 

yumyum113
Starting Member

31 Posts

Posted - 2007-03-02 : 19:53:29

Hi,

Hope someone could help me in revising a long running query. Here is the query

select *
from table1
where classid is null
and productid not in (
select productid
from table1
where classid = 67)

In here table1 could have several occurance of productid in which productid could have different classid. The possible values of classid are: NULL,1,2,3,67. Basically I am looking for all records whose classid is null but should never had an instance in table1 where its classid is 67.

Do you have something like a "join" statment that will only include all records in the left table that is not in the right table?

Hope someone could help me with this. Thanks in advance.

-Ruel

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-03-02 : 20:07:07
This forum is not for questions. You should post this on a TSQL forum.
"Script Library
This section is for any originally written scripts you'd like to share with the group."


CODO ERGO SUM
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-03 : 03:50:08
Also a cross posting
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=79974


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

yumyum113
Starting Member

31 Posts

Posted - 2007-03-03 : 22:45:53
How could I delete entire post?

-Ruel
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-04 : 00:16:51
You can click on the DELETE thread icon but only before anybody else reply to that thread


KH

Go to Top of Page
   

- Advertisement -