<?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/"
> <channel><title>Comments on: Selecting records from one table that dont have specific relationship in a second table</title> <atom:link href="http://www.mysqldiary.com/selecting-records-from-one-table-that-dont-have-specific-relationship-in-a-second-table/feed/" rel="self" type="application/rss+xml" /><link>http://www.mysqldiary.com/selecting-records-from-one-table-that-dont-have-specific-relationship-in-a-second-table/</link> <description>Exploring, Sharing and  Discussing MySQL practice</description> <lastBuildDate>Thu, 02 Feb 2012 09:16:49 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Amy</title><link>http://www.mysqldiary.com/selecting-records-from-one-table-that-dont-have-specific-relationship-in-a-second-table/comment-page-1/#comment-1121</link> <dc:creator>Amy</dc:creator> <pubDate>Sat, 05 Jun 2010 01:50:37 +0000</pubDate> <guid
isPermaLink="false">http://www.mysqldiary.com/?p=58#comment-1121</guid> <description>SELECT A.* FROM A
LEFT OUTER JOIN L
ON L.question_id = A.question_id
AND L.category_id = X
WHERE L.category_id IS NULL</description> <content:encoded><![CDATA[<p>SELECT A.* FROM A<br
/> LEFT OUTER JOIN L<br
/> ON L.question_id = A.question_id<br
/> AND L.category_id = X<br
/> WHERE L.category_id IS NULL</p> ]]></content:encoded> </item> <item><title>By: Hazan Ilan</title><link>http://www.mysqldiary.com/selecting-records-from-one-table-that-dont-have-specific-relationship-in-a-second-table/comment-page-1/#comment-255</link> <dc:creator>Hazan Ilan</dc:creator> <pubDate>Wed, 27 Jan 2010 20:53:26 +0000</pubDate> <guid
isPermaLink="false">http://www.mysqldiary.com/?p=58#comment-255</guid> <description>The condition &lt;code&gt;(L.question_id = A.question_id AND L.category_id = X)&lt;/code&gt;
at the ON clause force the left join to match only the records that DO have the X category. In other words, the records &lt;strong&gt;without&lt;/strong&gt; the X category will be the records with null values. All you need, in order to get only those with the null values (records that not in category X), is to restrict the query to retrieve only the records with null by putting &lt;code&gt;L.category_id IS NULL&lt;/code&gt; at the WHERE clause.</description> <content:encoded><![CDATA[<p>The condition <code>(L.question_id = A.question_id AND L.category_id = X)</code><br
/> at the ON clause force the left join to match only the records that DO have the X category. In other words, the records <strong>without</strong> the X category will be the records with null values. All you need, in order to get only those with the null values (records that not in category X), is to restrict the query to retrieve only the records with null by putting <code>L.category_id IS NULL</code> at the WHERE clause.</p> ]]></content:encoded> </item> <item><title>By: gloria</title><link>http://www.mysqldiary.com/selecting-records-from-one-table-that-dont-have-specific-relationship-in-a-second-table/comment-page-1/#comment-252</link> <dc:creator>gloria</dc:creator> <pubDate>Wed, 27 Jan 2010 14:45:23 +0000</pubDate> <guid
isPermaLink="false">http://www.mysqldiary.com/?p=58#comment-252</guid> <description>SELECT A.* FROM A
LEFT OUTER JOIN L
ON L.question_id = A.question_id
AND L.category_id = X
WHERE L.category_id IS NULL
I don&#039;t understand that when we are taking the condition as  L.category_id  is NULL then Why are we taking the  joining condition as L.Category_id=X</description> <content:encoded><![CDATA[<p>SELECT A.* FROM A<br
/> LEFT OUTER JOIN L<br
/> ON L.question_id = A.question_id<br
/> AND L.category_id = X<br
/> WHERE L.category_id IS NULL</p><p>I don&#8217;t understand that when we are taking the condition as  L.category_id  is NULL then Why are we taking the  joining condition as L.Category_id=X</p> ]]></content:encoded> </item> <item><title>By: Hazan Ilan</title><link>http://www.mysqldiary.com/selecting-records-from-one-table-that-dont-have-specific-relationship-in-a-second-table/comment-page-1/#comment-98</link> <dc:creator>Hazan Ilan</dc:creator> <pubDate>Tue, 19 Jan 2010 08:15:46 +0000</pubDate> <guid
isPermaLink="false">http://www.mysqldiary.com/?p=58#comment-98</guid> <description>This is a great query. Thanks</description> <content:encoded><![CDATA[<p>This is a great query. Thanks</p> ]]></content:encoded> </item> <item><title>By: rudy</title><link>http://www.mysqldiary.com/selecting-records-from-one-table-that-dont-have-specific-relationship-in-a-second-table/comment-page-1/#comment-97</link> <dc:creator>rudy</dc:creator> <pubDate>Tue, 19 Jan 2010 04:02:31 +0000</pubDate> <guid
isPermaLink="false">http://www.mysqldiary.com/?p=58#comment-97</guid> <description>SELECT A.* FROM A
LEFT OUTER JOIN L
ON L.question_id = A.question_id
AND L.category_id = X
WHERE L.category_id IS NULL</description> <content:encoded><![CDATA[<p>SELECT A.* FROM A<br
/> LEFT OUTER JOIN L<br
/> ON L.question_id = A.question_id<br
/> AND L.category_id = X<br
/> WHERE L.category_id IS NULL</p> ]]></content:encoded> </item> <item><title>By: Burak</title><link>http://www.mysqldiary.com/selecting-records-from-one-table-that-dont-have-specific-relationship-in-a-second-table/comment-page-1/#comment-95</link> <dc:creator>Burak</dc:creator> <pubDate>Tue, 19 Jan 2010 00:41:59 +0000</pubDate> <guid
isPermaLink="false">http://www.mysqldiary.com/?p=58#comment-95</guid> <description>If you just need the questions, and not every single category:
SELECT A.*, SUM(IF(L.category_id = X,1,0)) as count_x LEFT JOIN L USING(question_id) WHERE count_x = 0 GROUP BY question_id;</description> <content:encoded><![CDATA[<p>If you just need the questions, and not every single category:</p><p>SELECT A.*, SUM(IF(L.category_id = X,1,0)) as count_x LEFT JOIN L USING(question_id) WHERE count_x = 0 GROUP BY question_id;</p> ]]></content:encoded> </item> </channel> </rss>
