manderson2006
Programmer
Here's my scenario:
I have two tables: PhotoAlbums (Album_ID, Album_Name) and Photos (Photo_ID, Photo_Name, Album_ID).
What I want to do is to display all of the Photo Albums with one randomly chosen photo from each Photo Album.
What SQL should I use to do this? Here's what I have right now:
SELECT A.Album_Name, P.Photo_Name FROM PhotoAlbums A, Photos P WHERE A.Album_ID = P.Album_ID
Obviously this doesn't work because every photo for every album will be displayed, instead of just one photo for each album.
Can someone help me here?
Thanks!
I have two tables: PhotoAlbums (Album_ID, Album_Name) and Photos (Photo_ID, Photo_Name, Album_ID).
What I want to do is to display all of the Photo Albums with one randomly chosen photo from each Photo Album.
What SQL should I use to do this? Here's what I have right now:
SELECT A.Album_Name, P.Photo_Name FROM PhotoAlbums A, Photos P WHERE A.Album_ID = P.Album_ID
Obviously this doesn't work because every photo for every album will be displayed, instead of just one photo for each album.
Can someone help me here?
Thanks!