<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Convert WHERE to LEFT JOIN in cust_trans_db SQL]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=4796</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=4796&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Convert WHERE to LEFT JOIN in cust_trans_db SQL.]]></description>
		<lastBuildDate>Fri, 14 Mar 2014 13:08:04 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Convert WHERE to LEFT JOIN in cust_trans_db SQL]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=19524#p19524</link>
			<description><![CDATA[<p>Should we then use <strong>INNER JOINS</strong> for all joins here? </p><p>Thank you for the explanation of the differences.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Fri, 14 Mar 2014 13:08:04 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=19524#p19524</guid>
		</item>
		<item>
			<title><![CDATA[Re: Convert WHERE to LEFT JOIN in cust_trans_db SQL]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=19517#p19517</link>
			<description><![CDATA[<p>The same as in previous post. LEFT JOIN is used when records joined on the right are optional. This is not the case.<br />Janusz</p>]]></description>
			<author><![CDATA[null@example.com (itronics)]]></author>
			<pubDate>Fri, 14 Mar 2014 09:45:01 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=19517#p19517</guid>
		</item>
		<item>
			<title><![CDATA[Convert WHERE to LEFT JOIN in cust_trans_db SQL]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=19482#p19482</link>
			<description><![CDATA[<div class="codebox"><pre><code>--- sales/includes/db/cust_trans_db.inc    Mon Mar 10 16:17:12 2014
+++ sales/includes/db/cust_trans_db.inc    Wed Dec 25 19:00:22 2013
@@ -377,19 +377,19 @@
             Sum(line.quantity-line.qty_done) AS Outstanding,
             Sum(line.qty_done) AS Done
         FROM &quot;
-         .TB_PREF.&quot;sales_orders as sorder, &quot;
-         .TB_PREF.&quot;debtor_trans as trans, &quot;
-         .TB_PREF.&quot;debtor_trans_details as line, &quot;
-         .TB_PREF.&quot;debtors_master as debtor, &quot;
-         .TB_PREF.&quot;cust_branch as branch
-            WHERE
-            sorder.order_no = trans.order_ AND
-            trans.debtor_no = debtor.debtor_no
-                AND trans.type = &quot;.ST_CUSTDELIVERY.&quot;
-                AND line.debtor_trans_no = trans.trans_no
-                AND line.debtor_trans_type = trans.type
-                AND trans.branch_code = branch.branch_code
-                AND trans.debtor_no = branch.debtor_no &quot;;
+            .TB_PREF.&quot;sales_orders as sorder LEFT JOIN &quot;
+            .TB_PREF.&quot;debtor_trans as trans 
+                ON (sorder.order_no = trans.order_) LEFT JOIN &quot;
+            .TB_PREF.&quot;debtor_trans_details as line 
+                ON (line.debtor_trans_no = trans.trans_no
+                    AND line.debtor_trans_type = trans.type) LEFT JOIN &quot;
+            .TB_PREF.&quot;debtors_master as debtor
+                ON (trans.debtor_no = debtor.debtor_no) LEFT JOIN &quot;
+            .TB_PREF.&quot;cust_branch as branch 
+                ON (trans.branch_code = branch.branch_code
+                    AND trans.debtor_no = branch.debtor_no)
+        WHERE
+            trans.type = &quot;.ST_CUSTDELIVERY;
 
     if ($_POST[&#039;OutstandingOnly&#039;] == true) {
          $sql .= &quot; AND line.qty_done &lt; line.quantity &quot;;</code></pre></div><p>Joe, please include this patch in the core FA repo. It moves most of the WHERE statements to the LEFT JOINs.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Wed, 12 Mar 2014 16:01:16 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=19482#p19482</guid>
		</item>
	</channel>
</rss>
