<?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; A Quick Puzzle on JOIN and NULL &#8211; SQL Brain Teaser</title>
	<atom:link href="http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Thu, 23 May 2013 14:22:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #016 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-422311</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #016 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 16 Feb 2013 01:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-422311</guid>
		<description><![CDATA[[...]  A Quick Puzzle on JOIN and NULL – SQL Brain Teaser It seems that we all love to solve puzzles. On SQLAuthority Page, we have been playing the number game and those who are playing with us know how much fun we are having. Sometimes, the answers are so innovative and informative that they open up those aspects of the technology which I have not thought of. [...]]]></description>
		<content:encoded><![CDATA[<p>[...]  A Quick Puzzle on JOIN and NULL – SQL Brain Teaser It seems that we all love to solve puzzles. On SQLAuthority Page, we have been playing the number game and those who are playing with us know how much fun we are having. Sometimes, the answers are so innovative and informative that they open up those aspects of the technology which I have not thought of. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Litesh</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-279786</link>
		<dc:creator><![CDATA[Litesh]]></dc:creator>
		<pubDate>Thu, 26 Apr 2012 12:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-279786</guid>
		<description><![CDATA[Hi Pinal,

I have a different question on Joins, could you please state the reason why we have case in-sensitive joins on SQL Server?
I have worked on different databases as well and we have case sensitive joins there. Is there a specific reason for this kind of behavior?

Following SQL returns the data irrespective of the join conditions.

SELECT * FROM TABLE1 A
INNER JOIN TABLE2 B
ON UPPER(A.NAME)=LOWER(B.NAME);

Thanks in advance!!

Regards,
Litesh]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I have a different question on Joins, could you please state the reason why we have case in-sensitive joins on SQL Server?<br />
I have worked on different databases as well and we have case sensitive joins there. Is there a specific reason for this kind of behavior?</p>
<p>Following SQL returns the data irrespective of the join conditions.</p>
<p>SELECT * FROM TABLE1 A<br />
INNER JOIN TABLE2 B<br />
ON UPPER(A.NAME)=LOWER(B.NAME);</p>
<p>Thanks in advance!!</p>
<p>Regards,<br />
Litesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: qutubmumbai</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-254811</link>
		<dc:creator><![CDATA[qutubmumbai]]></dc:creator>
		<pubDate>Tue, 21 Feb 2012 11:35:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-254811</guid>
		<description><![CDATA[Hi Pinal,

Can you please help us understand whats the difference between Full Join and Cartisian product, because in above puzzel, when there are null values in the both tables i get two records in the result of Full join query (which is what is answer to your Puzzel) but if i have any other number or value rather then null lets say 1, i am getting only 1 record as result of the same full join query.

Regards,
Qutub...]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Can you please help us understand whats the difference between Full Join and Cartisian product, because in above puzzel, when there are null values in the both tables i get two records in the result of Full join query (which is what is answer to your Puzzel) but if i have any other number or value rather then null lets say 1, i am getting only 1 record as result of the same full join query.</p>
<p>Regards,<br />
Qutub&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Riji</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-253645</link>
		<dc:creator><![CDATA[Riji]]></dc:creator>
		<pubDate>Fri, 17 Feb 2012 22:33:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-253645</guid>
		<description><![CDATA[SELECT st.col1
FROM FirstTable ft
right JOIN SecondTable st ON st.Col1 = ft.Col1
GO]]></description>
		<content:encoded><![CDATA[<p>SELECT st.col1<br />
FROM FirstTable ft<br />
right JOIN SecondTable st ON st.Col1 = ft.Col1<br />
GO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruishi</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-253548</link>
		<dc:creator><![CDATA[Ruishi]]></dc:creator>
		<pubDate>Fri, 17 Feb 2012 15:55:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-253548</guid>
		<description><![CDATA[SELECT st.col1
FROM FirstTable ft
Right outer JOIN 
(
	select Col1 from SecondTable 
	union all
	select NULL As Col1
)	As st
ON st.Col1 = ft.Col1]]></description>
		<content:encoded><![CDATA[<p>SELECT st.col1<br />
FROM FirstTable ft<br />
Right outer JOIN<br />
(<br />
	select Col1 from SecondTable<br />
	union all<br />
	select NULL As Col1<br />
)	As st<br />
ON st.Col1 = ft.Col1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Solution Part 2 &#8211; A Quick Puzzle on JOIN and NULL &#8211; SQL Brain Teaser &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-253353</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Solution Part 2 &#8211; A Quick Puzzle on JOIN and NULL &#8211; SQL Brain Teaser &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Fri, 17 Feb 2012 01:31:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-253353</guid>
		<description><![CDATA[[...] Question: A Quick Puzzle on JOIN and NULL – SQL Brain Teaser [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Question: A Quick Puzzle on JOIN and NULL – SQL Brain Teaser [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nikhildas</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-251857</link>
		<dc:creator><![CDATA[Nikhildas]]></dc:creator>
		<pubDate>Mon, 13 Feb 2012 06:14:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-251857</guid>
		<description><![CDATA[SELECT st.col1
FROM FirstTable ft
FULL OUTER JOIN SecondTable st ON st.Col1 = ft.Col1

Result :

col1
------
NULL
NULL]]></description>
		<content:encoded><![CDATA[<p>SELECT st.col1<br />
FROM FirstTable ft<br />
FULL OUTER JOIN SecondTable st ON st.Col1 = ft.Col1</p>
<p>Result :</p>
<p>col1<br />
&#8212;&#8212;<br />
NULL<br />
NULL</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-251239</link>
		<dc:creator><![CDATA[Ken]]></dc:creator>
		<pubDate>Sat, 11 Feb 2012 11:55:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-251239</guid>
		<description><![CDATA[&quot;when we compare NULL to any Value(Including NULL itself), The result will always be UNKNOWN (NULL).&quot; Technically, that isn&#039;t true. First, a comparison must always return true or false so the assesment of the comparison can be made. Second, the assesment of NULL=NULL will return true if &quot;SET ANSI_NULLS OFF&quot; is executed. If it is set on, (default) the result is false. Third, no matter what the setting is, the assesment of NULL=NULL will return true if you try to insert a second null field value into a uniquely constrained field. That was why the second insert in the first table wasn&#039;t a null value. And finally, fourth, you could truncate the second table and there still would be two null rows returned because the left join requires returning all the rows of the first table (unless a where clause overrides it)
For strange results try the following query setting the first statement off and on:
SET ANSI_NULLS ON
DECLARE @tbl TABLE(i1 int UNIQUE)
INSERT INTO @tbl VALUES (NULL),(2),(3),(4),(5)
SELECT a.i1 first
	FROM @tbl a
	WHERE a.i1 NOT IN (SELECT i1 FROM @tbl WHERE i1 IS NULL OR i1 = 3)
SELECT a.i1 second
	FROM @tbl a
	WHERE a.i1 NOT IN (SELECT i1 FROM @tbl WHERE i1 = 2)]]></description>
		<content:encoded><![CDATA[<p>&#8220;when we compare NULL to any Value(Including NULL itself), The result will always be UNKNOWN (NULL).&#8221; Technically, that isn&#8217;t true. First, a comparison must always return true or false so the assesment of the comparison can be made. Second, the assesment of NULL=NULL will return true if &#8220;SET ANSI_NULLS OFF&#8221; is executed. If it is set on, (default) the result is false. Third, no matter what the setting is, the assesment of NULL=NULL will return true if you try to insert a second null field value into a uniquely constrained field. That was why the second insert in the first table wasn&#8217;t a null value. And finally, fourth, you could truncate the second table and there still would be two null rows returned because the left join requires returning all the rows of the first table (unless a where clause overrides it)<br />
For strange results try the following query setting the first statement off and on:<br />
SET ANSI_NULLS ON<br />
DECLARE @tbl TABLE(i1 int UNIQUE)<br />
INSERT INTO @tbl VALUES (NULL),(2),(3),(4),(5)<br />
SELECT a.i1 first<br />
	FROM @tbl a<br />
	WHERE a.i1 NOT IN (SELECT i1 FROM @tbl WHERE i1 IS NULL OR i1 = 3)<br />
SELECT a.i1 second<br />
	FROM @tbl a<br />
	WHERE a.i1 NOT IN (SELECT i1 FROM @tbl WHERE i1 = 2)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamesh</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-251183</link>
		<dc:creator><![CDATA[Kamesh]]></dc:creator>
		<pubDate>Sat, 11 Feb 2012 07:03:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-251183</guid>
		<description><![CDATA[Hey sir you must design a course SSEPD(Sql server expertise with pinal dave)..i will make sure i m first to enroll.

About  puzzle it was nice please keep up updating with this tits n bits of sql.it makes us confident...]]></description>
		<content:encoded><![CDATA[<p>Hey sir you must design a course SSEPD(Sql server expertise with pinal dave)..i will make sure i m first to enroll.</p>
<p>About  puzzle it was nice please keep up updating with this tits n bits of sql.it makes us confident&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sumit</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-251173</link>
		<dc:creator><![CDATA[Sumit]]></dc:creator>
		<pubDate>Sat, 11 Feb 2012 05:31:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-251173</guid>
		<description><![CDATA[Hi Pinal,

I think we&#039;ll have to use below code into &#039;Missing T-SQL Statement&#039; section.

SELECT st.col1
FROM FirstTable ft
LEFT JOIN SecondTable st ON st.Col1 = ft.Col1
UNION ALL]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I think we&#8217;ll have to use below code into &#8216;Missing T-SQL Statement&#8217; section.</p>
<p>SELECT st.col1<br />
FROM FirstTable ft<br />
LEFT JOIN SecondTable st ON st.Col1 = ft.Col1<br />
UNION ALL</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Solution &#8211; A Quick Puzzle on JOIN and NULL &#8211; SQL Brain Teaser &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-251135</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Solution &#8211; A Quick Puzzle on JOIN and NULL &#8211; SQL Brain Teaser &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 11 Feb 2012 01:31:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-251135</guid>
		<description><![CDATA[[...] Comments       GA_googleFillSlot(&quot;sqlauthority_728x90&quot;);     &#171; SQL SERVER &#8211; A Quick Puzzle on JOIN and NULL &#8211; SQL Brain&#160;Teaser [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Comments       GA_googleFillSlot(&quot;sqlauthority_728x90&quot;);     &laquo; SQL SERVER &#8211; A Quick Puzzle on JOIN and NULL &#8211; SQL Brain&nbsp;Teaser [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: R Jagtap</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-251060</link>
		<dc:creator><![CDATA[R Jagtap]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 20:25:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-251060</guid>
		<description><![CDATA[R Jagtap
Your comment is awaiting moderation.
I agree with Samarth , we have to insert any value in the first table as null=null condition is like ]]></description>
		<content:encoded><![CDATA[<p>R Jagtap<br />
Your comment is awaiting moderation.<br />
I agree with Samarth , we have to insert any value in the first table as null=null condition is like </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: R Jagtap</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-251059</link>
		<dc:creator><![CDATA[R Jagtap]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 20:25:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-251059</guid>
		<description><![CDATA[I agree with Samarth , we have to insert any value in the first table as null=null condition  is like &quot;&quot;]]></description>
		<content:encoded><![CDATA[<p>I agree with Samarth , we have to insert any value in the first table as null=null condition  is like &#8220;&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sandy Miller</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-250989</link>
		<dc:creator><![CDATA[Sandy Miller]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 15:24:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-250989</guid>
		<description><![CDATA[Pinal,
Love the puzzle.  Keep them comming.  Love your Blog!]]></description>
		<content:encoded><![CDATA[<p>Pinal,<br />
Love the puzzle.  Keep them comming.  Love your Blog!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Juliana</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-250988</link>
		<dc:creator><![CDATA[Juliana]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 15:20:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-250988</guid>
		<description><![CDATA[SELECT st.col1
FROM FirstTable ft
FULL JOIN SecondTable st ON st.Col1 = ft.Col1
GO]]></description>
		<content:encoded><![CDATA[<p>SELECT st.col1<br />
FROM FirstTable ft<br />
FULL JOIN SecondTable st ON st.Col1 = ft.Col1<br />
GO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raunak Jhawar</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-250952</link>
		<dc:creator><![CDATA[Raunak Jhawar]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 12:30:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-250952</guid>
		<description><![CDATA[INSERT INTO FirstTable (Col1)
VALUES (&#039;&#039;)]]></description>
		<content:encoded><![CDATA[<p>INSERT INTO FirstTable (Col1)<br />
VALUES (&#8221;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashish jain</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-250815</link>
		<dc:creator><![CDATA[Ashish jain]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 05:23:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-250815</guid>
		<description><![CDATA[Hello Pinal Sir,
                      How r u ?
                      
Samarth reply is correct.

INSERT INTO FirstTable (Col1)
VALUES (4)

we cant insert any value in the FirstTable to crate a second row. Left Outer join will return all rows from the Left table(Two rows in this case). 

Reason For this output : we are getting right table colum( col1 ) from this query. It will return NULL for both rows because when we compare NULL to any Value(Including NULL itself), The result will always be UNKNOWN (NULL).



Thanks,
Ashish Jain]]></description>
		<content:encoded><![CDATA[<p>Hello Pinal Sir,<br />
                      How r u ?</p>
<p>Samarth reply is correct.</p>
<p>INSERT INTO FirstTable (Col1)<br />
VALUES (4)</p>
<p>we cant insert any value in the FirstTable to crate a second row. Left Outer join will return all rows from the Left table(Two rows in this case). </p>
<p>Reason For this output : we are getting right table colum( col1 ) from this query. It will return NULL for both rows because when we compare NULL to any Value(Including NULL itself), The result will always be UNKNOWN (NULL).</p>
<p>Thanks,<br />
Ashish Jain</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-250807</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 05:05:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-250807</guid>
		<description><![CDATA[We all start with small and go to next level.]]></description>
		<content:encoded><![CDATA[<p>We all start with small and go to next level.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yrbyogiesh</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-250806</link>
		<dc:creator><![CDATA[yrbyogiesh]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 05:00:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-250806</guid>
		<description><![CDATA[you are providing simplest form of SQL. I am hoping much more from your side. You are master &amp; teach us to become expert on SQL.]]></description>
		<content:encoded><![CDATA[<p>you are providing simplest form of SQL. I am hoping much more from your side. You are master &amp; teach us to become expert on SQL.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chirag Satasiya</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-250803</link>
		<dc:creator><![CDATA[Chirag Satasiya]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 04:45:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-250803</guid>
		<description><![CDATA[Hi Pinal sir,

We like this type puzzle. Its like game and fun.

Here we have the expected resultset :

SELECT st.col1
FROM FirstTable ft
LEFT JOIN SecondTable st ON st.Col1 = ft.Col1

UNION ALL

SELECT st.col1
FROM FirstTable ft
RIGHT JOIN SecondTable st ON st.Col1 = ft.Col1

Explanation :
First we can&#039;t use INNER JOIN, it provides blank resultset.
So we have to go with other joins.

By running first query we are getting result from FirstTable.
We also want multiple NULL values from that.
We have to take out NULL from Second Table by RIGHT OUTER JOIN.


Regard$
Chirag Satasiya]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal sir,</p>
<p>We like this type puzzle. Its like game and fun.</p>
<p>Here we have the expected resultset :</p>
<p>SELECT st.col1<br />
FROM FirstTable ft<br />
LEFT JOIN SecondTable st ON st.Col1 = ft.Col1</p>
<p>UNION ALL</p>
<p>SELECT st.col1<br />
FROM FirstTable ft<br />
RIGHT JOIN SecondTable st ON st.Col1 = ft.Col1</p>
<p>Explanation :<br />
First we can&#8217;t use INNER JOIN, it provides blank resultset.<br />
So we have to go with other joins.</p>
<p>By running first query we are getting result from FirstTable.<br />
We also want multiple NULL values from that.<br />
We have to take out NULL from Second Table by RIGHT OUTER JOIN.</p>
<p>Regard$<br />
Chirag Satasiya</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samarth</title>
		<link>http://blog.sqlauthority.com/2012/02/10/sql-server-a-quick-puzzle-on-join-and-null-brain-teaser/#comment-250757</link>
		<dc:creator><![CDATA[Samarth]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 02:12:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=17281#comment-250757</guid>
		<description><![CDATA[INSERT INTO FirstTable (Col1)
VALUES (1)]]></description>
		<content:encoded><![CDATA[<p>INSERT INTO FirstTable (Col1)<br />
VALUES (1)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
