iHack Posted December 10, 2007 Share Posted December 10, 2007 Hey, I've got a table 'hits', I need to select 'song' from 'hits' in order of the value of 'song' most appearing (descending). Any help will be greatly appreciated. Thanks, EDIT: Latest MySQL (5) Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/ Share on other sites More sharing options...
beansandsausages Posted December 10, 2007 Share Posted December 10, 2007 need to use sum it like $select = mysql_query("SELECT from 'hits' WHERE users='$var['users']' ORDER BY DESC limit 0, 50"); that is a idea it wont work cos im not that good but mite be what your looking for. Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411003 Share on other sites More sharing options...
iHack Posted December 10, 2007 Author Share Posted December 10, 2007 need to use sum it like $select = mysql_query("SELECT from 'hits' WHERE users='$var['users']' ORDER BY DESC limit 0, 50"); that is a idea it wont work cos im not that good but mite be what your looking for. I don't that will work, its just a SELECT, WHERE. Sorry, the column name I need to ORDER and SELECT by is called 'song', my mistake Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411006 Share on other sites More sharing options...
beansandsausages Posted December 10, 2007 Share Posted December 10, 2007 yeah it was just a example, Do you want a particula song of a list of them?? Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411009 Share on other sites More sharing options...
iHack Posted December 10, 2007 Author Share Posted December 10, 2007 yeah it was just a example, Do you want a particula song of a list of them?? Nope. I want to get 'song' and and order by most occurrences of 'song', from 'hits'. Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411020 Share on other sites More sharing options...
beansandsausages Posted December 10, 2007 Share Posted December 10, 2007 yeah it was just a example, Do you want a particula song of a list of them?? Nope. I want to get 'song' and and order by most occurrences of 'song', from 'hits'. by occurrences you mean how many people downloaded them etc .... ? Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411024 Share on other sites More sharing options...
iHack Posted December 10, 2007 Author Share Posted December 10, 2007 Sort of, somebody opens a song it enters the song 'name' and user 'IP' into 'hits', the user can only do this twice to prevent refreshing and get a song popular. I'm trying to make the popularity table of songs from the hits table. James. Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411028 Share on other sites More sharing options...
beansandsausages Posted December 10, 2007 Share Posted December 10, 2007 okay try this think its kinda what you want ; $song = mysql_query("SELECT * FROM 'hits' WHERE song='song name or what ever' ORDER BY DESC 0, 50 ); think that is what you want if not sorry. Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411034 Share on other sites More sharing options...
iHack Posted December 10, 2007 Author Share Posted December 10, 2007 okay try this think its kinda what you want ; $song = mysql_query("SELECT * FROM 'hits' WHERE song='song name or what ever' ORDER BY DESC 0, 50 ); think that is what you want if not sorry. I don't want to specify a specific song name (so no WHERE, I think). I need to get a list of all song 'name's in order of the must occurring 'name' . Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411044 Share on other sites More sharing options...
beansandsausages Posted December 10, 2007 Share Posted December 10, 2007 haha got what you mean sorry my fault 2 may beers try : $select = ("SELECT 'songs' from 'hits' ORDER BY DESC "); sumit like that ? Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411055 Share on other sites More sharing options...
iHack Posted December 10, 2007 Author Share Posted December 10, 2007 haha got what you mean sorry my fault 2 may beers try : $select = ("SELECT 'songs' from 'hits' ORDER BY DESC "); sumit like that ? Simply put, no. :S Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411065 Share on other sites More sharing options...
beansandsausages Posted December 10, 2007 Share Posted December 10, 2007 well have no idea what you want sorry :'( Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411075 Share on other sites More sharing options...
trq Posted December 10, 2007 Share Posted December 10, 2007 SELECT song, COUNT(song) as total FROM hits GROUP BY song ORDER BY total; Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411077 Share on other sites More sharing options...
beansandsausages Posted December 10, 2007 Share Posted December 10, 2007 i was trien hahaha see how easy you made it thorpe Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411078 Share on other sites More sharing options...
trq Posted December 10, 2007 Share Posted December 10, 2007 Hehe, I have no idea if that will work or not. Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411087 Share on other sites More sharing options...
iHack Posted December 10, 2007 Author Share Posted December 10, 2007 Hehe, I have no idea if that will work or not. Thanks, that worked perfectly. Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411092 Share on other sites More sharing options...
beansandsausages Posted December 10, 2007 Share Posted December 10, 2007 @thorpe what the count(song) do count how many times its pulled from the db? Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411102 Share on other sites More sharing options...
fenway Posted December 10, 2007 Share Posted December 10, 2007 Hehe, I have no idea if that will work or not. Indeed it will. Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411103 Share on other sites More sharing options...
fenway Posted December 10, 2007 Share Posted December 10, 2007 @thorpe what the count(song) do count how many times its pulled from the db? It counts the number of times a given song name shows up in your recordset... I don't know what "pulled from the db" means. Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411105 Share on other sites More sharing options...
beansandsausages Posted December 10, 2007 Share Posted December 10, 2007 my wording isnt very good sorry. but yeah i understand now learned some thing new Link to comment https://forums.phpfreaks.com/topic/81015-select-and-order-by-most-common/#findComment-411107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.