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 Link to comment https://forums.phpfreaks.com/topic/120208-distinct-using-two-tables/ 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; Link to comment https://forums.phpfreaks.com/topic/120208-distinct-using-two-tables/#findComment-619305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.