Crusader Posted January 15, 2008 Share Posted January 15, 2008 This is a table called "tagged" id post_id tag_id 1 206 6 2 206 8 3 206 4 4 206 3 5 206 2 6 205 3 7 205 8 8 205 2 9 204 4 10 204 2 11 203 3 12 203 2 13 202 4 14 202 2 How would i get the first tag_id for each post_id? I've tried something like this but I don't know where to go from there... SELECT * FROM `tagged` WHERE post_id IN(202,206) Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86097-get-top-1-from-each-where-clause/ Share on other sites More sharing options...
toplay Posted January 15, 2008 Share Posted January 15, 2008 SELECT t.* FROM (SELECT * FROM `tagged` ORDER BY post_id ASC, tag_id ASC ) AS t GROUP BY t.post_id ; Quote Link to comment https://forums.phpfreaks.com/topic/86097-get-top-1-from-each-where-clause/#findComment-439666 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.