Revision 91bfa82d
Von Moritz Bunkus vor fast 18 Jahren hinzugefügt
SL/GL.pm | ||
---|---|---|
638 | 638 |
|
639 | 639 |
# retrieve individual rows |
640 | 640 |
$query = qq|SELECT c.accno, t.taxkey AS accnotaxkey, a.amount, a.memo, |
641 |
a.transdate, a.cleared, a.project_id, p.projectnumber,(SELECT p.projectnumber FROM project p
|
|
642 |
WHERE a.project_id = p.id) AS projectnumber, a.taxkey, t.rate AS taxrate, t.id, (SELECT c1.accno FROM chart c1, tax t1 WHERE t1.id=t.id AND c1.id=t.chart_id) AS taxaccno, (SELECT tk.tax_id FROM taxkeys tk WHERE tk.chart_id =a.chart_id AND tk.startdate<=a.transdate ORDER BY tk.startdate desc LIMIT 1) AS tax_id
|
|
641 |
a.transdate, a.cleared, a.project_id, p.projectnumber, |
|
642 |
a.taxkey, t.rate AS taxrate, t.id, (SELECT c1.accno FROM chart c1, tax t1 WHERE t1.id=t.id AND c1.id=t.chart_id) AS taxaccno, (SELECT tk.tax_id FROM taxkeys tk WHERE tk.chart_id =a.chart_id AND tk.startdate<=a.transdate ORDER BY tk.startdate desc LIMIT 1) AS tax_id |
|
643 | 643 |
FROM acc_trans a |
644 | 644 |
JOIN chart c ON (c.id = a.chart_id) |
645 | 645 |
LEFT JOIN project p ON (p.id = a.project_id) |
Auch abrufbar als: Unified diff
Projektnummer nicht doppelt und schon gar nicht mit einem Subquery abholen.