Please start any new threads on our new site at http://forums.sqlteam.com. 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
Username:
Password:
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  

yumyum113
Starting Member

Philippines
31 Posts

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

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)

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


CODO ERGO SUM
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30421 Posts

Posted - 03/03/2007 :  03:50:08  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

Philippines
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?

-Ruel
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
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


KH

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