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.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 alternative to subselect query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

31 Posts

Posted - 03/02/2007 :  19:53:29  Show Profile  Send yumyum113 a Yahoo! Message  Reply with Quote


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 - 03/02/2007 :  20:07:07  Show Profile  Reply with Quote
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 - 03/03/2007 :  03:50:08  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Also a cross posting

Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Starting Member

31 Posts

Posted - 03/03/2007 :  22:45:53  Show Profile  Send yumyum113 a Yahoo! Message  Reply with Quote
How could I delete entire post?

Go to Top of Page

In (Som, Ni, Yak)

17689 Posts

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


Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2019 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000