i am developing a query where by i want to select information from 1 table1 and count the corresponding rows of another table2 while i select the unique row from that table2 corresponding table
e.g.
Code: Select all
---table2---
id | foregin key
1 | 2
2 | 2
3 | 2
4 | 1
5 | 1
6 | 6
----table1---
id
1
2
3
4
5
61,2,6 from table1 counting each occurance in table2 and selecting 1,4,6 from table2
i have com up with this thus far
Code: Select all
SELECT DISTINCTROW
`galleries`.`GalleryID`,
`galleries`.`Title`,
`galleries`.`Description`,
COUNT(`photos`.`Gallery`) AS `photoCount`,
`photos`.`PhotoID`
FROM
`galleries`,
`photos`
WHERE
(`galleries`.`Status` = 1)
GROUP BY
`galleries`.`GalleryID`,
`galleries`.`Title`,
`galleries`.`Description`,
`photos`.`Gallery`im puzzled why as i have selected using DISTINCTROW
anyone care to point out the problem or a solutions
Kendall