gtjr92
Programmer
- May 26, 2004
- 96
I have 3 tables Albums, Photos, Videos
The albums table is related to the videos table by the albumid in the video table. The album table is also related to the photo table by the albumid field.
I want to get the count of the videoid's that are related to the albumid and also a seperate unrelated count of the Photoid count that is in the albumid
If I run a quey like this by itself
That works I get the count of the videos. I run a similir query and get the count of photoid in each album id.
So I tried to run one query and get the counts of the photo id's and video id. I tried this
This ends up giving me the same count for the countofphotos as the countofvideos. ie it says i have 20 videos in an album and 20 photos when really it is just giving me the photos count in both the video and photo counts results. One last thing there is a field thumbnailid in the photo table that is related to the thumbnailid column in videos. This field is not relevent to the data i need.
The albums table is related to the videos table by the albumid in the video table. The album table is also related to the photo table by the albumid field.
I want to get the count of the videoid's that are related to the albumid and also a seperate unrelated count of the Photoid count that is in the albumid
If I run a quey like this by itself
Code:
SELECT COUNT(Videos.VideoID) AS vidscount, Albums.AlbumID, Albums.Caption, Albums.AlbumCategoryID
FROM Albums INNER JOIN
Videos ON Albums.AlbumID = Videos.AlbumID
GROUP BY Albums.AlbumID, Albums.Caption, Albums.AlbumCategoryID, Videos.AlbumID
So I tried to run one query and get the counts of the photo id's and video id. I tried this
Code:
SELECT
[Albums].[AlbumID],
[Albums].[AlbumCategoryID],
[Albums].[Caption],
[Albums].[IsPublic],
Count([Photos].[PhotoID]) AS NumberOfPhotos,
Count([Videos].[VideoID]) As NumberofVideos
FROM [Albums] LEFT JOIN [Photos]
ON [Albums].[AlbumID] = [Photos].[AlbumID]
LEFT JOIN [Videos]
ON [Albums].[AlbumID] = [Videos].[AlbumID]
GROUP BY
[Albums].[AlbumCategoryID],
[Albums].[AlbumID],
[Albums].[Caption],
[Albums].[IsPublic]