<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Convert WHERE to LEFT JOIN in cust_trans_db SQL]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=4796&amp;type=atom" />
	<updated>2014-03-14T13:08:04Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=4796</id>
		<entry>
			<title type="html"><![CDATA[Re: Convert WHERE to LEFT JOIN in cust_trans_db SQL]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=19524#p19524" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2014-03-14T13:08:04Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=19524#p19524</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Convert WHERE to LEFT JOIN in cust_trans_db SQL]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=19517#p19517" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[itronics]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=89</uri>
			</author>
			<updated>2014-03-14T09:45:01Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=19517#p19517</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Convert WHERE to LEFT JOIN in cust_trans_db SQL]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=19482#p19482" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2014-03-12T16:01:16Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=19482#p19482</id>
		</entry>
</feed>
