Hi there 8) Im just wondering how I can prevent the query from outputing the same name twice in a query? Example: If I query and it outputs: Name- Age- Location- Roger 23 New York Eric 29 Miami Eric 48 Boston Is there a way to make it recognize that it already outputed "Eric" then make it skip the next eric so it just outputs: Name- Age- Location- Roger 23 New York Eric 29 Miami ? Thanks alot guys
GROUP BY will get you the distinct names, but the rest of the output (age and location) won't make any sense.
You will probably have to run a subquery to pull distinct names from your database and then link that back to your main query so that you only output one record per name. Hopefully you have an autonumber id field on that table. Do you? Also, what makes the 'Eric, 29, Miami' record get outputted while the 'Eric, 48, Boston' not? How do you want the system to determine which record for each name to display?
group by can be used to group one kind of data and distinct can be used to avoid duplication of data in display
How you want decide that from: Eric 29 Miami Eric 48 Boston Is correct first Eric and not second one? Is there some order logic? Cause if you want just list of names, then you can use SELECT DISTINCT name FROM yourTable If you need age and location as well, these 2 records are different. You need to give us clue how to select first record (Min, Max, first based on some order etc.)