私は次のmysqlクエリを持っています:
SELECT sku, quantity, inventory.isbn13, author, title, pub_date, binding,
defect.defect, source, location from inventory
LEFT JOIN location ON inventory.location_id = location.location_id
LEFT JOIN source ON inventory.source_id = source.source_id
LEFT JOIN book ON inventory.isbn13 = book.isbn13
LEFT JOIN defect ON inventory.defect_id = defect.defect_id
LEFT JOIN book_condition ON book_condition.condition_id = defect.condition_id
WHERE quantity > '0' and location.location_id >= '986' and location.location_id <= '989'
ORDER BY inventory.location_id, sku
これは完全に機能しますが、ロケーションIDごとに本の総数を表示する必要があります。たとえば、location_id 986には17冊の本があり、location_id 987には34冊の本があります。この情報を取得するには、2番目のクエリを実行する必要がありますか、それとも私が持っているクエリでこれを行う方法はありますか?
ありがとうジム