Help requested, please -- the MySQL part of my brain is obviously not at the right caffeine level.

Over the years, we have used a lot of "shelves" (authorized values, mostly temporary boxes) and now I need to identify the "empty" ones as a cleanup/caretaking excercise.

The following SQL query works syntactically, and finds any shelf with at least one item:

SELECT authorised_values.authorised_value AS Auth_Location,
COUNT(DISTINCT biblioitems.biblionumber) as Quantity
FROM biblioitems
LEFT JOIN items ON (items.biblioitemnumber=biblioitems.biblioitemnumber)
LEFT JOIN authorised_values ON (authorised_values.authorised_value=items.location)
WHERE authorised_values.category LIKE 'loc'
GROUP BY authorised_values.authorised_value HAVING COUNT(DISTINCT biblioitems.biblionumber)>0;

but if I change the final >0 to =0 it fails to find any empty box ;={

I'm sort-of convinced that this comes from JOINing the authorised_values.authorised_value to the items.location (obviously that location no longer exists in items), but am going in circles looking for an alternate method.

Thanks in advance -- Paul


_______________________________________________
Koha mailing list  http://koha-community.org
Koha@lists.katipo.co.nz
http://lists.katipo.co.nz/mailman/listinfo/koha

Reply via email to