drisate Posted February 20, 2009 Share Posted February 20, 2009 hey guys, how can i select the username that has appeared the most in a colum? SELECT attname FROM war order by count(id) desc limit 1 Thats not working Quote Link to comment https://forums.phpfreaks.com/topic/146177-select-prob/ Share on other sites More sharing options...
The Little Guy Posted February 20, 2009 Share Posted February 20, 2009 Something like this: SELECT COUNT(attname) FROM war GROUP BY attname Quote Link to comment https://forums.phpfreaks.com/topic/146177-select-prob/#findComment-767432 Share on other sites More sharing options...
drisate Posted February 20, 2009 Author Share Posted February 20, 2009 hmmm nope and this si not working to SELECT COUNT(attname) as num FROM war GROUP BY attname order by num Quote Link to comment https://forums.phpfreaks.com/topic/146177-select-prob/#findComment-767436 Share on other sites More sharing options...
The Little Guy Posted February 20, 2009 Share Posted February 20, 2009 Try it like this: SELECT COUNT(id) as num FROM war GROUP BY attname DESC If that doesn't work, please explain what the result is doing. Quote Link to comment https://forums.phpfreaks.com/topic/146177-select-prob/#findComment-767440 Share on other sites More sharing options...
drisate Posted February 20, 2009 Author Share Posted February 20, 2009 nope that outputs a number. i need it to output the value of attname The number is not even good thought Quote Link to comment https://forums.phpfreaks.com/topic/146177-select-prob/#findComment-767445 Share on other sites More sharing options...
The Little Guy Posted February 20, 2009 Share Posted February 20, 2009 could you give me an example output that you want? Quote Link to comment https://forums.phpfreaks.com/topic/146177-select-prob/#findComment-767449 Share on other sites More sharing options...
premiso Posted February 20, 2009 Share Posted February 20, 2009 SELECT attname, count(id) as num FROM war GROUP BY attname Should do it, given that the primary key field is "id" Quote Link to comment https://forums.phpfreaks.com/topic/146177-select-prob/#findComment-767450 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.