I've got 2 tables, albums
and pictures
...
pictures
has relation to albums
via fk_albumID
.
Now want im trying is to select all from albums
, and at the same time count how many pictures that has relation to albums
...
I tried with:
SELECT *, (SELECT COUNT(*) FROM pictures WHERE pictures.fk_albumID = albums.albumID) AS albumCount FROM pictures, albums
But this first of all dont return any results if theres no pictures at all... And then it repeats results according to count. So if albums has 3 pictures, then i will get the album 3 times in my list, when i bind it to a Repeater.
And i tried:
SELECT COUNT(albums.albumID) AS albumCount, albums.albumName, albums.albumID FROM albums INNER JOIN pictures ON pictures.fk_albumID = albums.albumID GROUP BY albums.albumID, albums.albuName
But this only shows albums that has pictures...