For some reason I can't figure this out. I have a table that holds information about books called BKLIST. There is a second table called ImageLocation that holds information about the related images. I am trying to return the Title and Author fields from the BKLIST table along with a count of how many images are associated with that particular title. The two tables are related through the RecordID field in BKLIST and the BookID field in ImageLocation. The statement is based on a search so there is a having clause. The following statement works if the title has associated images, but returns nothing if there are no images. I want to return all the titles, even if the image count is 0. Any help would be appreciated!
SELECT BKLIST.TITLE, BKLIST.AUTHOR, COUNT(ImageLocation.BookID)
AS numImages
FROM BKLIST INNER JOIN
ImageLocation ON
BKLIST.Record# = ImageLocation.BookID
GROUP BY BKLIST.TITLE, BKLIST.AUTHOR
HAVING (BKLIST.TITLE LIKE N'%USSR%')
SELECT BKLIST.TITLE, BKLIST.AUTHOR, COUNT(ImageLocation.BookID)
AS numImages
FROM BKLIST INNER JOIN
ImageLocation ON
BKLIST.Record# = ImageLocation.BookID
GROUP BY BKLIST.TITLE, BKLIST.AUTHOR
HAVING (BKLIST.TITLE LIKE N'%USSR%')