<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Eddie Awad’s Blog - Latest Comments in Back to basics: self joins</title><link>http://awads.disqus.com/</link><description>News, views, tips and tricks on Oracle and other fun stuff</description><atom:link href="https://awads.disqus.com/back_to_basics_self_joins/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 31 May 2007 03:36:48 -0000</lastBuildDate><item><title>Re: Back to basics: self joins</title><link>http://awads.net/wp/2006/07/11/back-to-basics-self-joins/#comment-3658688</link><description>&lt;p&gt;As stated by Eddie:&lt;br&gt;WHERE d1.department_id IN (10, 20, 30, 40)&lt;br&gt;   AND d2.department_id IN (10, 20, 30, 40);&lt;br&gt;What if the department_ids are around 100 in number, would it not be a roblem to enter all department_ids in the query. Using Oracle I can solve it, however using ANSI do we have to use a subquery there as in Oracle or is there a seperate way. Please let me know.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Sukaina</dc:creator><pubDate>Thu, 31 May 2007 03:36:48 -0000</pubDate></item><item><title>Re: Back to basics: self joins</title><link>http://awads.net/wp/2006/07/11/back-to-basics-self-joins/#comment-3658686</link><description>&lt;p&gt;Yas, you're right, the corrected statement that describes&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;WHERE e.manager_id = m.employee_id (+)&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;is:&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;The (+) operator following m.employee_id means that you want to display a row from the e table, even though there exists no corresponding row in the m table.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Thanks for catching it.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Wed, 12 Jul 2006 12:46:39 -0000</pubDate></item><item><title>Re: Back to basics: self joins</title><link>http://awads.net/wp/2006/07/11/back-to-basics-self-joins/#comment-3658685</link><description>&lt;p&gt;Just a bit off topic.&lt;br&gt;I clicked on the Spain's flag on top of the screen and the text it showed make no sense at all!&lt;br&gt;The damn thing even translate the code so it is a bit futile to run that translation.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nelson</dc:creator><pubDate>Wed, 12 Jul 2006 10:27:38 -0000</pubDate></item><item><title>Re: Back to basics: self joins</title><link>http://awads.net/wp/2006/07/11/back-to-basics-self-joins/#comment-3658687</link><description>&lt;p&gt;&lt;i&gt;The (+) operator following m.employee_id means that you want to display a row from the m table, even though there exists no corresponding row in the e table&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Eddie, i think it must be the other way around. This code gets all rows from e, not m. This (+) is usually confusing to many people, it makes the sql get all the rows from the table on the other side.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">yas</dc:creator><pubDate>Wed, 12 Jul 2006 05:12:49 -0000</pubDate></item><item><title>Re: Back to basics: self joins</title><link>http://awads.net/wp/2006/07/11/back-to-basics-self-joins/#comment-3658684</link><description>&lt;p&gt;Hi Rob,&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;The difference between using JOIN/ON and just using WHERE is that the first uses the ANSI/ISO SQL92 standard syntax, and the second uses the good old Oracle syntax.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;I refer you to &lt;a href="http://awads.net/wp/2006/03/16/back-to-basics-cross-joins/" rel="nofollow noopener" target="_blank" title="http://awads.net/wp/2006/03/16/back-to-basics-cross-joins/"&gt;this post&lt;/a&gt; for some discussion about the difference between the two and the advantages/disadvantages of using the ANSI SQL syntax (make sure you read &lt;a href="http://awads.net/wp/2006/03/16/back-to-basics-cross-joins/#comments" rel="nofollow noopener" target="_blank" title="http://awads.net/wp/2006/03/16/back-to-basics-cross-joins/#comments"&gt;the comments&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;By the way,&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;FROM employees e LEFT OUTER JOIN employees m&lt;br&gt;   ON e.manager_id = m.employee_id&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;translates to&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;    FROM employees e, employees m&lt;br&gt; WHERE e.manager_id = m.employee_id (+)&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;The (+) operator following m.employee_id means that you want to display a row from the m table, even though there exists no corresponding row in the e table, and that's what the LEFT OUTER JOIN above means.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Tue, 11 Jul 2006 21:45:10 -0000</pubDate></item><item><title>Re: Back to basics: self joins</title><link>http://awads.net/wp/2006/07/11/back-to-basics-self-joins/#comment-3658683</link><description>&lt;p&gt;What is the difference between using JOIN/ON and just using WHERE?&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;For example, take your second query, and instead make it&lt;br&gt;FROM employee e, employee m WHERE e.manager_id(+) = m.employee_id&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;I've never used the JOIN/ON syntax.  Does it have an advantage?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Robert Vollman</dc:creator><pubDate>Tue, 11 Jul 2006 18:25:25 -0000</pubDate></item></channel></rss>