<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Interesting Observation of ON Clause on LEFT JOIN &#8211; How ON Clause affects Resultset in LEFT JOIN</title>
	<atom:link href="http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 24 May 2013 22:47:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: priyaranjan</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-462582</link>
		<dc:creator><![CDATA[priyaranjan]]></dc:creator>
		<pubDate>Wed, 24 Apr 2013 04:12:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-462582</guid>
		<description><![CDATA[excellent !!!!! Blog , Thanks.]]></description>
		<content:encoded><![CDATA[<p>excellent !!!!! Blog , Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sivas Cvas</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-444715</link>
		<dc:creator><![CDATA[Sivas Cvas]]></dc:creator>
		<pubDate>Tue, 26 Mar 2013 11:36:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-444715</guid>
		<description><![CDATA[SELECT *
FROM 
(
	SELECT * FROM #DEL2 WHERE FLAG=1
) A
LEFT JOIN 
(
	SELECT * FROM #DEL1
) B ON A.ID=B.ID]]></description>
		<content:encoded><![CDATA[<p>SELECT *<br />
FROM<br />
(<br />
	SELECT * FROM #DEL2 WHERE FLAG=1<br />
) A<br />
LEFT JOIN<br />
(<br />
	SELECT * FROM #DEL1<br />
) B ON A.ID=B.ID</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SIVAS</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-444710</link>
		<dc:creator><![CDATA[SIVAS]]></dc:creator>
		<pubDate>Tue, 26 Mar 2013 11:29:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-444710</guid>
		<description><![CDATA[CREATE TABLE #DEL1(ID INT IDENTITY(1,1),VALUE VARCHAR(MAX),FLAG CHAR(1))

CREATE TABLE #DEL2(ID INT IDENTITY(1,1),VALUE VARCHAR(MAX),FLAG CHAR(1))

INSERT INTO #DEL1 VALUES(&#039;1ST&#039;,1),(&#039;2ND&#039;,1),(&#039;3RD&#039;,2),(&#039;4TH&#039;,1),(&#039;5TH&#039;,2),(&#039;6TH&#039;,1)

INSERT INTO #DEL2 VALUES(&#039;1ST&#039;,1),(&#039;2ND&#039;,1),(&#039;3RD&#039;,2),(&#039;4TH&#039;,2),(&#039;5TH&#039;,2)

SELECT * FROM #DEL1
SELECT * FROM #DEL2


---------------------------------------------------------------
-- LEFT JOIN with Additional Condition on ON clause
SELECT *
FROM #DEL1 A
LEFT JOIN #DEL2 B ON A.ID=B.ID AND B.FLAG=1
---------------------------------------------------------------
/* EQUILENT TO THIS QRY */
SELECT *
FROM #DEL1 A
LEFT JOIN (SELECT * FROM #DEL2 WHERE FLAG=1) B ON A.ID=B.ID 
/* SO I OBSERVED THAT HERE ORDER OF EXECUTION IS FROM ,()PARANTHESIS,ON */
---------------------------------------------------------------

/*
NOTE : LEFT OUTER JOIN MEANS THAT MATCHING THE VALUES OF RIGHT SIDE TABLE AND UNMATCHING VALUES OF LEFT SIDE TABLE
.SO NOW THE QRY WILL BE LIKE THIS 

*/
---------------------------------------------------------------
SELECT *
FROM 
(
	SELECT * FROM #DEL2 WHERE FLAG=1
) A
LEFT JOIN 
(
	SELECT * FROM #DEL1
) B ON A.ID=B.ID AND A.FLAG=1
---------------------------------------------------------------
/* EQUILENT TO THIS QRY */
SELECT *
FROM #DEL1 A
LEFT JOIN #DEL2 B ON A.ID=B.ID 
WHERE B.FLAG=1
---------------------------------------------------------------
--CLEAN UP THE TABLES
DROP TABLE #DEL1
DROP TABLE #DEL2]]></description>
		<content:encoded><![CDATA[<p>CREATE TABLE #DEL1(ID INT IDENTITY(1,1),VALUE VARCHAR(MAX),FLAG CHAR(1))</p>
<p>CREATE TABLE #DEL2(ID INT IDENTITY(1,1),VALUE VARCHAR(MAX),FLAG CHAR(1))</p>
<p>INSERT INTO #DEL1 VALUES(&#8217;1ST&#8217;,1),(&#8217;2ND&#8217;,1),(&#8217;3RD&#8217;,2),(&#8217;4TH&#8217;,1),(&#8217;5TH&#8217;,2),(&#8217;6TH&#8217;,1)</p>
<p>INSERT INTO #DEL2 VALUES(&#8217;1ST&#8217;,1),(&#8217;2ND&#8217;,1),(&#8217;3RD&#8217;,2),(&#8217;4TH&#8217;,2),(&#8217;5TH&#8217;,2)</p>
<p>SELECT * FROM #DEL1<br />
SELECT * FROM #DEL2</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8211; LEFT JOIN with Additional Condition on ON clause<br />
SELECT *<br />
FROM #DEL1 A<br />
LEFT JOIN #DEL2 B ON A.ID=B.ID AND B.FLAG=1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
/* EQUILENT TO THIS QRY */<br />
SELECT *<br />
FROM #DEL1 A<br />
LEFT JOIN (SELECT * FROM #DEL2 WHERE FLAG=1) B ON A.ID=B.ID<br />
/* SO I OBSERVED THAT HERE ORDER OF EXECUTION IS FROM ,()PARANTHESIS,ON */<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>/*<br />
NOTE : LEFT OUTER JOIN MEANS THAT MATCHING THE VALUES OF RIGHT SIDE TABLE AND UNMATCHING VALUES OF LEFT SIDE TABLE<br />
.SO NOW THE QRY WILL BE LIKE THIS </p>
<p>*/<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
SELECT *<br />
FROM<br />
(<br />
	SELECT * FROM #DEL2 WHERE FLAG=1<br />
) A<br />
LEFT JOIN<br />
(<br />
	SELECT * FROM #DEL1<br />
) B ON A.ID=B.ID AND A.FLAG=1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
/* EQUILENT TO THIS QRY */<br />
SELECT *<br />
FROM #DEL1 A<br />
LEFT JOIN #DEL2 B ON A.ID=B.ID<br />
WHERE B.FLAG=1<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
&#8211;CLEAN UP THE TABLES<br />
DROP TABLE #DEL1<br />
DROP TABLE #DEL2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #020 &#124; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-438057</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #020 &#124; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 16 Mar 2013 01:30:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-438057</guid>
		<description><![CDATA[[...] Interesting Observation of ON Clause on LEFT JOIN – How ON Clause affects Resultset in LEFT JOIN When I want to filter records in a query, I usually put the condition in the WHERE clause. When I make an inner join, I can put the condition in the ON clause instead, giving the same result. But with left joins this is not the case. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Interesting Observation of ON Clause on LEFT JOIN – How ON Clause affects Resultset in LEFT JOIN When I want to filter records in a query, I usually put the condition in the WHERE clause. When I make an inner join, I can put the condition in the ON clause instead, giving the same result. But with left joins this is not the case. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shaun</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-433792</link>
		<dc:creator><![CDATA[shaun]]></dc:creator>
		<pubDate>Fri, 08 Mar 2013 08:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-433792</guid>
		<description><![CDATA[A way to understand this is to think of an inner join as a filter only showing rows where the on condition match.

A outer join keeps all records of the outer table and fill in data on the outer table based on the on condition. if there is not a match in the on condition data will not be joined on the outer table.

This is how I understand it and mabe it can help others]]></description>
		<content:encoded><![CDATA[<p>A way to understand this is to think of an inner join as a filter only showing rows where the on condition match.</p>
<p>A outer join keeps all records of the outer table and fill in data on the outer table based on the on condition. if there is not a match in the on condition data will not be joined on the outer table.</p>
<p>This is how I understand it and mabe it can help others</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arulraj</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-419365</link>
		<dc:creator><![CDATA[Arulraj]]></dc:creator>
		<pubDate>Fri, 08 Feb 2013 07:04:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-419365</guid>
		<description><![CDATA[Hi janani,
   Please try this....

Select a.EmpNo , b.Description 
from #temp1 a INNER JOIN #temp2 b 
  on (a.BadgeID = b.BadgeID OR A.BadgeID IS NULL)]]></description>
		<content:encoded><![CDATA[<p>Hi janani,<br />
   Please try this&#8230;.</p>
<p>Select a.EmpNo , b.Description<br />
from #temp1 a INNER JOIN #temp2 b<br />
  on (a.BadgeID = b.BadgeID OR A.BadgeID IS NULL)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doreen</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-367180</link>
		<dc:creator><![CDATA[Doreen]]></dc:creator>
		<pubDate>Wed, 31 Oct 2012 20:33:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-367180</guid>
		<description><![CDATA[Thanks Pinal ! Your blog is *always* helpful to me. I am learning T SQL after years of Oracle SQL. Thanks!
Doreen]]></description>
		<content:encoded><![CDATA[<p>Thanks Pinal ! Your blog is *always* helpful to me. I am learning T SQL after years of Oracle SQL. Thanks!<br />
Doreen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Satheesh</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-343647</link>
		<dc:creator><![CDATA[Satheesh]]></dc:creator>
		<pubDate>Thu, 13 Sep 2012 12:22:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-343647</guid>
		<description><![CDATA[&quot;point 2 )
what if

SELECT *
FROM Table1 t1
LEFT JOIN Table2 t2 ON t1.ID = t2.ID AND t1.Flag = 1&quot;

Even i have this question.. Did you get any solution for this?]]></description>
		<content:encoded><![CDATA[<p>&#8220;point 2 )<br />
what if</p>
<p>SELECT *<br />
FROM Table1 t1<br />
LEFT JOIN Table2 t2 ON t1.ID = t2.ID AND t1.Flag = 1&#8243;</p>
<p>Even i have this question.. Did you get any solution for this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-304397</link>
		<dc:creator><![CDATA[Sam]]></dc:creator>
		<pubDate>Fri, 22 Jun 2012 16:37:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-304397</guid>
		<description><![CDATA[Hi Pinal, 
First of all anything, I really appreciate your efforts and authority on Sql server; I was doing oracle and recently I started playing hands on MS Sql;  one of my friend referred your blog and believe me this is the first place I look if I have any question. 

Today, I had question using conditions within ON clause and I landed up here; This article is exactly my question and your explanation was superb but..... the part which I did not understood and challenge I am facing is .. 

What if I apply conditions on first table  
relating to your above example - 
SELECT *
FROM Table1 t1
LEFT JOIN Table2 t2 ON t1.ID = t2.ID AND t1.Flag != 1  -- or using t1.Flag = 2

I expected the result to be: 
     T1                    T2 
Value  Flag      Value  Flag
Third   2            Third  2 
Fifth    2             Null   Null 
Seventh 2         Null   Null 

but its also returning all values of table-1 with Flag =1 and joining with table - 2.

I did not run your tables but I have a similar example. Please guide me if I am missing anything; I thought using condition within ON clause improves performance since it reduces the number of rows to be joined based on the conditions.  Please suggest and clarify. 

Thanks, 
Sam.]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
First of all anything, I really appreciate your efforts and authority on Sql server; I was doing oracle and recently I started playing hands on MS Sql;  one of my friend referred your blog and believe me this is the first place I look if I have any question. </p>
<p>Today, I had question using conditions within ON clause and I landed up here; This article is exactly my question and your explanation was superb but&#8230;.. the part which I did not understood and challenge I am facing is .. </p>
<p>What if I apply conditions on first table<br />
relating to your above example &#8211;<br />
SELECT *<br />
FROM Table1 t1<br />
LEFT JOIN Table2 t2 ON t1.ID = t2.ID AND t1.Flag != 1  &#8212; or using t1.Flag = 2</p>
<p>I expected the result to be:<br />
     T1                    T2<br />
Value  Flag      Value  Flag<br />
Third   2            Third  2<br />
Fifth    2             Null   Null<br />
Seventh 2         Null   Null </p>
<p>but its also returning all values of table-1 with Flag =1 and joining with table &#8211; 2.</p>
<p>I did not run your tables but I have a similar example. Please guide me if I am missing anything; I thought using condition within ON clause improves performance since it reduces the number of rows to be joined based on the conditions.  Please suggest and clarify. </p>
<p>Thanks,<br />
Sam.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janani</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-192041</link>
		<dc:creator><![CDATA[janani]]></dc:creator>
		<pubDate>Thu, 10 Nov 2011 04:24:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-192041</guid>
		<description><![CDATA[This is not i Expect....
By the by,... EmpNo and BadgeID can&#039;t be equal all the time..
 
Any way, .. thanks.... for your try..

I need to get TextDescription from Master table for the corresponding ID in transaction table.
Thats all the concept.. if the corresponding ID is not available in Master table.,, we have to omit that record While fetching from Trasaction table.

Thats it...........]]></description>
		<content:encoded><![CDATA[<p>This is not i Expect&#8230;.<br />
By the by,&#8230; EmpNo and BadgeID can&#8217;t be equal all the time..</p>
<p>Any way, .. thanks&#8230;. for your try..</p>
<p>I need to get TextDescription from Master table for the corresponding ID in transaction table.<br />
Thats all the concept.. if the corresponding ID is not available in Master table.,, we have to omit that record While fetching from Trasaction table.</p>
<p>Thats it&#8230;&#8230;&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raghav</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-191631</link>
		<dc:creator><![CDATA[Raghav]]></dc:creator>
		<pubDate>Wed, 09 Nov 2011 14:54:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-191631</guid>
		<description><![CDATA[How do you get &#039;NULL&#039; in the Description column if there isn&#039;t such record in that column. May be you want the result as:

EmpNo   Description
--------------------------
1             Mixing
2             Simplex


If it is so, then you can try out the query this way:

SELECT a.EmpNo , b.Description FROM #temp1 a
INNER JOIN #temp2 b ON a.EmpNo = b.BadgeID



Regards,
Raghav]]></description>
		<content:encoded><![CDATA[<p>How do you get &#8216;NULL&#8217; in the Description column if there isn&#8217;t such record in that column. May be you want the result as:</p>
<p>EmpNo   Description<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
1             Mixing<br />
2             Simplex</p>
<p>If it is so, then you can try out the query this way:</p>
<p>SELECT a.EmpNo , b.Description FROM #temp1 a<br />
INNER JOIN #temp2 b ON a.EmpNo = b.BadgeID</p>
<p>Regards,<br />
Raghav</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janani</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-191491</link>
		<dc:creator><![CDATA[janani]]></dc:creator>
		<pubDate>Wed, 09 Nov 2011 09:48:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-191491</guid>
		<description><![CDATA[Create table #temp1(EmpNo int Identity Not Null, BadgeID int Null )
Insert into #temp1 values (1)
Insert into #temp1 values (NULL)
Insert into #temp1 values (3)

Create table #temp2(BadgeID int Identity Not NUll, Description varchar(20) Not NUll)
Insert into #temp2 values ( &#039;Mixing&#039;)
Insert into #temp2 values ( &#039;Simplex&#039;)
Insert into #temp2 values ( &#039;Combing&#039;)
Insert into #temp2 values ( &#039;Adidas&#039;)

Delete from #temp2 where Description = &#039;Combing&#039;

--------------------------------------------

Select * from #temp1 

Result:
EmpNo	BadgeID
1	1
2	NULL
3	3
---------------------------------------------

Select * from #temp2 

Result :
BadgeID	Description
1	Mixing
2	Simplex
4	Adidas
--------------------------------------------

Select a.EmpNo , b.Description   from #temp1 a
left outer join 
#temp2 b on a.BadgeID = b.BadgeID 

Result:
EmpNo	Description
1	Mixing
2	NULL
3	NULL

From the above Result, i want to eliminate the last record  EmpNo = 3, since its Corresponding BadgeID 3 is not in table #temp2.

I want the result as :

EmpNo	Description
1	Mixing
2	NULL]]></description>
		<content:encoded><![CDATA[<p>Create table #temp1(EmpNo int Identity Not Null, BadgeID int Null )<br />
Insert into #temp1 values (1)<br />
Insert into #temp1 values (NULL)<br />
Insert into #temp1 values (3)</p>
<p>Create table #temp2(BadgeID int Identity Not NUll, Description varchar(20) Not NUll)<br />
Insert into #temp2 values ( &#8216;Mixing&#8217;)<br />
Insert into #temp2 values ( &#8216;Simplex&#8217;)<br />
Insert into #temp2 values ( &#8216;Combing&#8217;)<br />
Insert into #temp2 values ( &#8216;Adidas&#8217;)</p>
<p>Delete from #temp2 where Description = &#8216;Combing&#8217;</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Select * from #temp1 </p>
<p>Result:<br />
EmpNo	BadgeID<br />
1	1<br />
2	NULL<br />
3	3<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Select * from #temp2 </p>
<p>Result :<br />
BadgeID	Description<br />
1	Mixing<br />
2	Simplex<br />
4	Adidas<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Select a.EmpNo , b.Description   from #temp1 a<br />
left outer join<br />
#temp2 b on a.BadgeID = b.BadgeID </p>
<p>Result:<br />
EmpNo	Description<br />
1	Mixing<br />
2	NULL<br />
3	NULL</p>
<p>From the above Result, i want to eliminate the last record  EmpNo = 3, since its Corresponding BadgeID 3 is not in table #temp2.</p>
<p>I want the result as :</p>
<p>EmpNo	Description<br />
1	Mixing<br />
2	NULL</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-191480</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 09 Nov 2011 09:29:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-191480</guid>
		<description><![CDATA[Generic approach

update t1
set t1.col=t2.col
from table1 as t1 inner join table2 as t2 on t1.keycol=t2.keycol
where t2.somecol=]]></description>
		<content:encoded><![CDATA[<p>Generic approach</p>
<p>update t1<br />
set t1.col=t2.col<br />
from table1 as t1 inner join table2 as t2 on t1.keycol=t2.keycol<br />
where t2.somecol=</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-191477</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 09 Nov 2011 09:25:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-191477</guid>
		<description><![CDATA[What does this return?

SELECT *
FROM Table1 t1
INNER JOIN Table2 t2 ON t1.ID = t2.ID]]></description>
		<content:encoded><![CDATA[<p>What does this return?</p>
<p>SELECT *<br />
FROM Table1 t1<br />
INNER JOIN Table2 t2 ON t1.ID = t2.ID</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janani</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-191318</link>
		<dc:creator><![CDATA[janani]]></dc:creator>
		<pubDate>Wed, 09 Nov 2011 04:35:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-191318</guid>
		<description><![CDATA[How to handle the above logic with optimized query.

Thank you

Regards
janani.S]]></description>
		<content:encoded><![CDATA[<p>How to handle the above logic with optimized query.</p>
<p>Thank you</p>
<p>Regards<br />
janani.S</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janani</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-187047</link>
		<dc:creator><![CDATA[janani]]></dc:creator>
		<pubDate>Wed, 02 Nov 2011 13:02:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-187047</guid>
		<description><![CDATA[Yes i tried..  it returns everything....

My Issue is , i want to eliminate records if ID is not available in table t2

Note : t1.Id is Nullable Column in table t1
t2.Id is Not Nullable and Identity Column in table t2]]></description>
		<content:encoded><![CDATA[<p>Yes i tried..  it returns everything&#8230;.</p>
<p>My Issue is , i want to eliminate records if ID is not available in table t2</p>
<p>Note : t1.Id is Nullable Column in table t1<br />
t2.Id is Not Nullable and Identity Column in table t2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-187042</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 02 Nov 2011 12:56:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-187042</guid>
		<description><![CDATA[Did you try this?

SELECT *
FROM Table1 t1
LEFT JOIN Table2 t2 ON t1.ID = t2.ID WHERE t2.Flag is null]]></description>
		<content:encoded><![CDATA[<p>Did you try this?</p>
<p>SELECT *<br />
FROM Table1 t1<br />
LEFT JOIN Table2 t2 ON t1.ID = t2.ID WHERE t2.Flag is null</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janani</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-187018</link>
		<dc:creator><![CDATA[janani]]></dc:creator>
		<pubDate>Wed, 02 Nov 2011 12:12:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-187018</guid>
		<description><![CDATA[hai Pinal… 

Please Give me Solution for the below Problem!!!!!!!!

SELECT *
FROM Table1 t1
LEFT JOIN Table2 t2 ON t1.ID = t2.ID AND t2.Flag is null

———-

How To Hanle the Query…

If i want want to eliminate Resultant Record when t2.Id is Not Available in Table t2 and t1.Id is Not Null from the above Query Result



Note : t1.Id is Nullable Column in table t1
t2.Id is Not Nullable and Identity Column in table t2]]></description>
		<content:encoded><![CDATA[<p>hai Pinal… </p>
<p>Please Give me Solution for the below Problem!!!!!!!!</p>
<p>SELECT *<br />
FROM Table1 t1<br />
LEFT JOIN Table2 t2 ON t1.ID = t2.ID AND t2.Flag is null</p>
<p>———-</p>
<p>How To Hanle the Query…</p>
<p>If i want want to eliminate Resultant Record when t2.Id is Not Available in Table t2 and t1.Id is Not Null from the above Query Result</p>
<p>Note : t1.Id is Nullable Column in table t1<br />
t2.Id is Not Nullable and Identity Column in table t2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janani</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-186845</link>
		<dc:creator><![CDATA[janani]]></dc:creator>
		<pubDate>Wed, 02 Nov 2011 07:13:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-186845</guid>
		<description><![CDATA[hai Pinal... 

Please Give me Solution for the below Problem!!!!!!!!

SELECT *
FROM Table1 t1
LEFT JOIN Table2 t2 ON t1.ID = t2.ID AND t2.Flag is null

———-

How To Hanle the Query...

If i want want to eliminate Resultant Record when t2.Id is Not Available in Table t2 and t1.Id is Not Null from the above Query Result]]></description>
		<content:encoded><![CDATA[<p>hai Pinal&#8230; </p>
<p>Please Give me Solution for the below Problem!!!!!!!!</p>
<p>SELECT *<br />
FROM Table1 t1<br />
LEFT JOIN Table2 t2 ON t1.ID = t2.ID AND t2.Flag is null</p>
<p>———-</p>
<p>How To Hanle the Query&#8230;</p>
<p>If i want want to eliminate Resultant Record when t2.Id is Not Available in Table t2 and t1.Id is Not Null from the above Query Result</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janani</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-186836</link>
		<dc:creator><![CDATA[janani]]></dc:creator>
		<pubDate>Wed, 02 Nov 2011 07:01:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-186836</guid>
		<description><![CDATA[SELECT *
FROM Table1 t1
LEFT JOIN Table2 t2 ON t1.ID = t2.ID AND t2.Flag is null

----------

How To Hanle Left Join ...
If i want want to eliminate Resultant Record when t2.Id is Not Available in Table t2 from the above Query Result]]></description>
		<content:encoded><![CDATA[<p>SELECT *<br />
FROM Table1 t1<br />
LEFT JOIN Table2 t2 ON t1.ID = t2.ID AND t2.Flag is null</p>
<p>&#8212;&#8212;&#8212;-</p>
<p>How To Hanle Left Join &#8230;<br />
If i want want to eliminate Resultant Record when t2.Id is Not Available in Table t2 from the above Query Result</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jroughgarden</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-175074</link>
		<dc:creator><![CDATA[jroughgarden]]></dc:creator>
		<pubDate>Tue, 04 Oct 2011 15:41:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-175074</guid>
		<description><![CDATA[David Bridge, you are right. Pinal Dave is a hero! 

But we do all make mistakes with grammar and punctuation at times, especially when there is no spelling or grammar checker. For example, you failed to punctuate the word &#039;however&#039; correctly in your comment and misplaced the period as well. Your sentende should have read:

(Effect can also be an adjective depending on how it is used; however, affect is always a verb os it is doing something to something else.)

So it goes. I think the meaning of your comment as well as the meaning of Pinal Dave&#039;s title are completely clear. So I would call your comment and mine both nitpicks.

:&gt;)]]></description>
		<content:encoded><![CDATA[<p>David Bridge, you are right. Pinal Dave is a hero! </p>
<p>But we do all make mistakes with grammar and punctuation at times, especially when there is no spelling or grammar checker. For example, you failed to punctuate the word &#8216;however&#8217; correctly in your comment and misplaced the period as well. Your sentende should have read:</p>
<p>(Effect can also be an adjective depending on how it is used; however, affect is always a verb os it is doing something to something else.)</p>
<p>So it goes. I think the meaning of your comment as well as the meaning of Pinal Dave&#8217;s title are completely clear. So I would call your comment and mine both nitpicks.</p>
<p>:&gt;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-174965</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Tue, 04 Oct 2011 09:54:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-174965</guid>
		<description><![CDATA[Thank you so much.

I am very very glad to have your email and comment. I value and appreciate it 100%. Only friends give feedback.]]></description>
		<content:encoded><![CDATA[<p>Thank you so much.</p>
<p>I am very very glad to have your email and comment. I value and appreciate it 100%. Only friends give feedback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: davidbridge</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-174955</link>
		<dc:creator><![CDATA[davidbridge]]></dc:creator>
		<pubDate>Tue, 04 Oct 2011 09:31:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-174955</guid>
		<description><![CDATA[A very small grammatical error but sadly as it is in the title, I thought I would bring it to your attention. 

I realise that English is not your main language and totally admire your ability to master it and write such fantastic articles using it. I hope that you are not offended to be informed of this slight error in what is a very misunderstood area of the language.

“SQL SERVER – Interesting Observation of ON Clause on LEFT JOIN – How ON Clause Effects Resultset in LEFT JOIN”

Should be

“SQL SERVER – Interesting Observation of ON Clause on LEFT JOIN – How ON Clause affects Resultset in LEFT JOIN”

The difference being the word Affects (Effects). 
Affect is a verb where one thing affects another.
Effect is a noun where we see the effect that one thing had on the other.
(Effect can also be an adjective depending on how it is used however affect is always a verb os it is doing something to something else).

I think you have done a really good job of explaining the issue. I have often had to explain this weird behaviour to DB developers but in future I think I will simply point them at your example.

Regards

Dave]]></description>
		<content:encoded><![CDATA[<p>A very small grammatical error but sadly as it is in the title, I thought I would bring it to your attention. </p>
<p>I realise that English is not your main language and totally admire your ability to master it and write such fantastic articles using it. I hope that you are not offended to be informed of this slight error in what is a very misunderstood area of the language.</p>
<p>“SQL SERVER – Interesting Observation of ON Clause on LEFT JOIN – How ON Clause Effects Resultset in LEFT JOIN”</p>
<p>Should be</p>
<p>“SQL SERVER – Interesting Observation of ON Clause on LEFT JOIN – How ON Clause affects Resultset in LEFT JOIN”</p>
<p>The difference being the word Affects (Effects).<br />
Affect is a verb where one thing affects another.<br />
Effect is a noun where we see the effect that one thing had on the other.<br />
(Effect can also be an adjective depending on how it is used however affect is always a verb os it is doing something to something else).</p>
<p>I think you have done a really good job of explaining the issue. I have often had to explain this weird behaviour to DB developers but in future I think I will simply point them at your example.</p>
<p>Regards</p>
<p>Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shruti</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-132858</link>
		<dc:creator><![CDATA[Shruti]]></dc:creator>
		<pubDate>Wed, 04 May 2011 12:45:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-132858</guid>
		<description><![CDATA[Thanks Pinal..

Your article saved me from committing a big mistake while writing a query.

Thanks for the good work]]></description>
		<content:encoded><![CDATA[<p>Thanks Pinal..</p>
<p>Your article saved me from committing a big mistake while writing a query.</p>
<p>Thanks for the good work</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: prashant</title>
		<link>http://blog.sqlauthority.com/2009/03/15/sql-server-interesting-observation-of-on-clause-on-left-join-how-on-clause-effects-resultset-in-left-join/#comment-89709</link>
		<dc:creator><![CDATA[prashant]]></dc:creator>
		<pubDate>Mon, 27 Sep 2010 09:36:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=3755#comment-89709</guid>
		<description><![CDATA[hi 

i have one query 
i want to update the data in table 1 based on certain condition which must be satisfy by table 2 how should i do this please give small example
waiting for u r reply

thanks]]></description>
		<content:encoded><![CDATA[<p>hi </p>
<p>i have one query<br />
i want to update the data in table 1 based on certain condition which must be satisfy by table 2 how should i do this please give small example<br />
waiting for u r reply</p>
<p>thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
