Sorry it's in a PHP forum, but PHP and MySQL work together, so it's quite relevant! I've got a table like so: id | year | name I'd like to select rows from it, grouped by year and name. So only rows where the year AND the name are the same. So the following data: id | year | name 1 | 2005 | John 2 | 2006 | Steve 3 | 2005 | Steve 4 | 2005 | John 5 | 2006 | Steve 6 | 2005 | Steve Would give: 2005 John 2006 Steve 2005 Steve Any ideas? Thanks!
Actually, I think I just solved it, Doh! I was using GROUP BY year AND name I should have used GROUP BY year, name Sorry to waste your time.
there are two ways to do this 1. Write a query 2. Write a php program I know the second one which is rather slow You can search manually by picking each individual record and find if that exist any record which matches more than once show (both year and name will come more than once) it otherwise not Regards Alex
Thanks for the post, but it doesn't help. Besides, I've already sorted the problem. Watch your postings as they could be regarded as spam and you could lose your account
$query = "SELECT `id`,`year`,`name` FROM `tblname` GROUP BY `year`,`name`"; Code (markup): should work.