haku Posted August 5, 2009 Share Posted August 5, 2009 I have a table with the following columns: nid, vid, title vids are all unique, but nids are often not. So for example I may have: nid vid title 1 2 ta 1 3 tb 2 4 tc 2 5 td I need to select the title for each nid that corresponds to the highest vid. For example, in the above example, I want two titles - one for each of the nids, and the two titles I want are tb and td, as they correspond to the highest vid values for each nid. Can someone give me a hand on this? I've been playing with it for a while, but it's not working for me. Gracias. Quote Link to comment https://forums.phpfreaks.com/topic/168931-solved-query-help/ Share on other sites More sharing options...
Maq Posted August 5, 2009 Share Posted August 5, 2009 SELECT title, MAX(vid) FROM table GROUP BY nid Quote Link to comment https://forums.phpfreaks.com/topic/168931-solved-query-help/#findComment-891305 Share on other sites More sharing options...
haku Posted August 5, 2009 Author Share Posted August 5, 2009 I feel kind of stupid now haha I don't actually need the NID itself, so I wasn't thinking to select it in order to narrow the results. But I guess I can just select it out, and not use it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/168931-solved-query-help/#findComment-891307 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.