From: Moritz Bunkus Date: Thu, 26 Apr 2007 15:35:43 +0000 (+0000) Subject: Query durch LEFT JOIN vereinfacht und die Ergebnisanzahl deutlich reduziert. X-Git-Tag: release-2.4.3^2~431 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=b49779f0e34edf56c8f1f22e5a68ba24452da400;p=kivitendo-erp.git Query durch LEFT JOIN vereinfacht und die Ergebnisanzahl deutlich reduziert. --- diff --git a/SL/Form.pm b/SL/Form.pm index da224ab74..cbc4df1b7 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1944,14 +1944,13 @@ sub create_links { } # now get the account numbers - $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id - FROM chart c, taxkeys tk - WHERE c.link LIKE ? - AND ( tk.chart_id = c.id OR c.link LIKE '%_tax%') - AND (NOT tk.chart_id = c.id OR NOT c.link LIKE '%_tax%') - AND (tk.id = (SELECT id FROM taxkeys WHERE taxkeys.chart_id = c.id AND startdate <= $transdate ORDER BY startdate DESC LIMIT 1) - OR c.link LIKE '%_tax%') - ORDER BY c.accno|; + $query = qq|SELECT c.accno, c.description, c.link, c.taxkey_id, tk.tax_id + FROM chart c + LEFT JOIN taxkeys tk ON (tk.chart_id = c.id) + WHERE c.link LIKE ? + AND (tk.id = (SELECT id FROM taxkeys WHERE taxkeys.chart_id = c.id AND startdate <= $transdate ORDER BY startdate DESC LIMIT 1) + OR c.link LIKE '%_tax%') + ORDER BY c.accno|; $sth = $dbh->prepare($query); do_statement($self, $sth, $query, "%$module%");