G
Guest
hi
i am trying to write a query to produce a descending recordset of photo_id
but only one from each user e.g
if these are the top records
photo_id 150 m_name dave
photo_id 149 m_name dave
photo_id 148 m_name dave
photo_id 147 m_name john
photo_id 146 m_name john
photo_id 145 m_name fred
i want the query to produce this
photo_id 150 m_name dave
photo_id 147 m_name john
photo_id 145 m_name fred
and so on, there are other fields also but that gives you the idea i hope.
what i have come up with is this
SELECT MAX(FORUM_ALBUM.Photo_id) AS ID,
FORUM_ALBUM.Photo_Name,FORUM_ALBUM_USERS.M_Name,FO RUM_ALBUM.Member_id
FROM FORUM_ALBUM, FORUM_ALBUM_USERS
WHERE FORUM_ALBUM.Member_id=FORUM_ALBUM_USERS.MEMBER_ID AND
FORUM_ALBUM.Photo_Status=1
GROUP BY FORUM_ALBUM.Photo_id,FORUM_ALBUM.Photo_Name,
FORUM_ALBUM_USERS.M_Name, FORUM_ALBUM.Member_id
ORDER BY FORUM_ALBUM.Photo_id DESC;
this gives me the records i want in the correct order but it gives multiple
instances of each M_Name instead of just one record for each M_Name
i hope i have explained this clearly enough
thanks
Dave
i am trying to write a query to produce a descending recordset of photo_id
but only one from each user e.g
if these are the top records
photo_id 150 m_name dave
photo_id 149 m_name dave
photo_id 148 m_name dave
photo_id 147 m_name john
photo_id 146 m_name john
photo_id 145 m_name fred
i want the query to produce this
photo_id 150 m_name dave
photo_id 147 m_name john
photo_id 145 m_name fred
and so on, there are other fields also but that gives you the idea i hope.
what i have come up with is this
SELECT MAX(FORUM_ALBUM.Photo_id) AS ID,
FORUM_ALBUM.Photo_Name,FORUM_ALBUM_USERS.M_Name,FO RUM_ALBUM.Member_id
FROM FORUM_ALBUM, FORUM_ALBUM_USERS
WHERE FORUM_ALBUM.Member_id=FORUM_ALBUM_USERS.MEMBER_ID AND
FORUM_ALBUM.Photo_Status=1
GROUP BY FORUM_ALBUM.Photo_id,FORUM_ALBUM.Photo_Name,
FORUM_ALBUM_USERS.M_Name, FORUM_ALBUM.Member_id
ORDER BY FORUM_ALBUM.Photo_id DESC;
this gives me the records i want in the correct order but it gives multiple
instances of each M_Name instead of just one record for each M_Name
i hope i have explained this clearly enough
thanks
Dave