Page 1 of 1

posting only one result if multiple results are equal

Posted: Wed Jul 06, 2011 8:53 am
by chrisflip8
Basically, I have a form that allows users to upload information to a mysql database. They input the last name of a person and write a comment about them. If people write about the same person, there will be multiple rows in the database with that same last name in the "name" field. Now I have it set up so people search by letter. So if there are 10 rows in the database with Smith as the last name, I don't want Smith to show up 10 times after the search. How can I get just one Smith to show up?? I'm using this a statement like this

SELECT lastname from tablename where lastname like 'S%' ... but obviosuly this gets me every row with a last name starting with S and duplicates if there is the same last name. PLEASE HELP!!

Thanks in advance.

Chris

Re: posting only one result if multiple results are equal

Posted: Wed Jul 06, 2011 9:20 am
by Celauran

Code: Select all

SELECT lastname FROM tablename WHERE lastname LIKE 'S%' GROUP BY lastname

Re: posting only one result if multiple results are equal

Posted: Wed Jul 06, 2011 9:45 am
by chrisflip8
Wow, that simple. Thank you so so much!!