corillo181 Posted June 9, 2008 Share Posted June 9, 2008 hi i have a table which is made of 4 fields id | art_id | song_id | clicks now what i want to do is sum all clicks where the art_id are the same so if i have id | art_id | song_id | clicks 1 23 43 100 2 10 99 34 3 23 44 50 when i do the query i get in return art_id | clicks 10 34 23 150 Link to comment https://forums.phpfreaks.com/topic/109396-solved-query-selection/ Share on other sites More sharing options...
bobinindia Posted June 9, 2008 Share Posted June 9, 2008 What is your query? Link to comment https://forums.phpfreaks.com/topic/109396-solved-query-selection/#findComment-561143 Share on other sites More sharing options...
corillo181 Posted June 9, 2008 Author Share Posted June 9, 2008 that is what im trying to find out.. how would i make a query that will sum that total clicks where artist_id are the same so something like sum(counter) where artist_id = artist_id Link to comment https://forums.phpfreaks.com/topic/109396-solved-query-selection/#findComment-561145 Share on other sites More sharing options...
corillo181 Posted June 9, 2008 Author Share Posted June 9, 2008 oh forget it i guess that works.. lol i was just typing it wrong.. Link to comment https://forums.phpfreaks.com/topic/109396-solved-query-selection/#findComment-561155 Share on other sites More sharing options...
bobinindia Posted June 9, 2008 Share Posted June 9, 2008 This is more of a MySQL question. You may do better in that forum. artist_id UNIQUE may be part of it. Link to comment https://forums.phpfreaks.com/topic/109396-solved-query-selection/#findComment-561162 Share on other sites More sharing options...
corillo181 Posted June 9, 2008 Author Share Posted June 9, 2008 SELECT `artist_id`, SUM(clicks) `total` FROM `song_clicks` WHERE `artist_id` != 0 GROUP BY `artist_id` this works just in case someone do a search for something like this. Link to comment https://forums.phpfreaks.com/topic/109396-solved-query-selection/#findComment-561164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.