forcom Posted June 5, 2009 Share Posted June 5, 2009 Table info id country state city 1 usa ny sample1 2 usa pa sample2 3 usa nj sample3 4 England no sample 4 I want to display a unique name no deplicates usa (3) England (1) can this be done. right now my code look something like this usa usa usa england Need help Quote Link to comment https://forums.phpfreaks.com/topic/161134-solved-need-help-with-controling-deplicates-in-a-loop/ Share on other sites More sharing options...
Maq Posted June 5, 2009 Share Posted June 5, 2009 SELECT DISTINCT country FROM table Do you want the count of each one as well? Quote Link to comment https://forums.phpfreaks.com/topic/161134-solved-need-help-with-controling-deplicates-in-a-loop/#findComment-850292 Share on other sites More sharing options...
forcom Posted June 5, 2009 Author Share Posted June 5, 2009 yes I would like that. I will try this code now. Quote Link to comment https://forums.phpfreaks.com/topic/161134-solved-need-help-with-controling-deplicates-in-a-loop/#findComment-850299 Share on other sites More sharing options...
Maq Posted June 6, 2009 Share Posted June 6, 2009 This should do was you want. SELECT country, COUNT(*) AS num FROM table GROUP BY country; Quote Link to comment https://forums.phpfreaks.com/topic/161134-solved-need-help-with-controling-deplicates-in-a-loop/#findComment-850613 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.