From b49779f0e34edf56c8f1f22e5a68ba24452da400 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 26 Apr 2007 15:35:43 +0000 Subject: [PATCH] Query durch LEFT JOIN vereinfacht und die Ergebnisanzahl deutlich reduziert. --- SL/Form.pm | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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%"); -- 2.20.1