Hi All,I have the following query:SELECT l.ID, l.LibraryName, SUM(o.total) as recs FROM( SELECT p.LibraryID, COUNT(p.LibraryID) AS total FROM products p GROUP BY p.LibraryID UNION SELECT t.LibraryID, COUNT(t.LibraryID) AS total FROM types t GROUP BY t.LibraryID)o INNER JOIN Libraries l ON l.ID = o.LibraryIDWHERE l.UserID = 559GROUP BY l.ID, l.LibraryNameORDER BY l.LibraryName
This works fine if the nested counts return a value but doesn't if there are no matching libraries in the types or products table. How can I exclude the count for 0 or return the id, libraryname, 0 when there are no matching records in the products/types table?