Mr Chris Posted August 18, 2008 Share Posted August 18, 2008 Hi All, I have two tables, a table called gallery, and a table called info Now both have a field called gallery_id Now in the gallery table the field gallery_id has lots of the same value ie: 5 so I want to get the DISTINT value, but the output displays the same value 5 in multiple rows. SELECT DISTINCT i.info_id, g.gallery_id, g.main_name, i.opening, i.headline, DATE_FORMAT(i.published, '%W, %D %M, %Y') AS formatted_date, i.gallery_id FROM gallery g, info i WHERE g.gallery_id=i.gallery_id Can anyone help? Thanks Chris Quote Link to comment Share on other sites More sharing options...
Hooker Posted August 18, 2008 Share Posted August 18, 2008 SELECT i.info_id, g.gallery_id, g.main_name, i.opening, i.headline, DATE_FORMAT(i.published, '%W, %D %M, %Y') AS formatted_date FROM gallery g INNER JOIN info i ON g.gallery_id = i.gallery_id GROUP BY g.gallery_id; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.