Please start any new threads on our new site at 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 

Starting Member

31 Posts

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


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.


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."

Go to Top of Page

Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-03 : 03:50:08
Also a cross posting

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Starting Member

31 Posts

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

Go to Top of Page

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


Go to Top of Page

- Advertisement -