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
posting only one result if multiple results are equal
Moderator: General Moderators
-
chrisflip8
- Forum Newbie
- Posts: 2
- Joined: Wed Jul 06, 2011 8:43 am
Re: posting only one result if multiple results are equal
Code: Select all
SELECT lastname FROM tablename WHERE lastname LIKE 'S%' GROUP BY lastname-
chrisflip8
- Forum Newbie
- Posts: 2
- Joined: Wed Jul 06, 2011 8:43 am
Re: posting only one result if multiple results are equal
Wow, that simple. Thank you so so much!!