[Koha-bugs] [Bug 14704] members/statistics.pl crashes because the SQL 'return'-keyword might be reserved at 'return FROM ('
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Tue Aug 25 10:59:30 CEST 2015
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14704
--- Comment #3 from Olli-Antti Kivilahti <olli-antti.kivilahti at jns.fi> ---
(In reply to Jonathan Druart from comment #2)
> I got the following if I execute directly the second query in my MariaDB CLI:
>
> ERROR 1054 (42S22): Unknown column 'tmp.return' in 'field list'
That is because my hastily created example SQL was missing explicit definition
for issues.return and old_issues.return.
This wasn't the case in the code (hopefully).
Try this:
SELECT COUNT(*) as count_precedent_state,tmp.issues,tmp.onloan,tmp.return
FROM (
SELECT it.*, i.return FROM issues i, items it
WHERE i.borrowernumber = 1234 AND
i.itemnumber = it.itemnumber AND
DATE(i.issuedate) < CAST(now() AS date)
UNION
SELECT it.*, oi.return FROM old_issues oi, items it
WHERE oi.borrowernumber = 1234 AND
oi.itemnumber = it.itemnumber AND
DATE(oi.issuedate) < CAST(now() AS date) AND
DATE(oi.returndate) = CAST(now() AS date)
) tmp
GROUP BY tmp.issues,tmp.onloan,tmp.return;
--
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
More information about the Koha-bugs
mailing list