Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 22nd, 2006, 03:40 AM
Authorized User
 
Join Date: Dec 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default join

HI,

I have a query in which in where clause I have used not in clause. Now I want to use join instead of it. Can I do it? If yes how?


Dharm

__________________
Dharmendra
Software Engineer
 
Old December 22nd, 2006, 10:21 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Can you post a sample of your code

Jaime E. Maccou
 
Old January 2nd, 2007, 12:39 AM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use a LEFT JOIN for this purpose. As an example, to convert the following NOT IN syntax:

SELECT * FROM TableA
WHERE ID NOT IN (SELECT ID FROM TableB)

You can do it this way using a LEFT JOIN:

SELECT *
FROM TableA A LEFT OUTER JOIN TableB B
ON A.ID = B.ID
WHERE B.ID IS NULL

You may also refer to Question #3 in the following link:

Frequently Asked Questions - SELECT Statement
http://www.sql-server-helper.com/faq/select-p01.aspx

SQL Server Helper
http://www.sql-server-helper.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm new to join oneilsteven BOOK: ASP.NET Website Programming Problem-Design-Solution 0 February 9th, 2008 06:07 PM
Join or not join madhukp SQL Server 2000 3 February 2nd, 2005 01:11 AM
More than one join jaywhy13 Classic ASP Basics 2 January 31st, 2005 11:38 PM
INNER JOIN msmagied Classic ASP Databases 3 August 29th, 2004 12:28 PM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.