Don't display duplicate results [HELP]

I have a query (probably not the most efficient way of doing it but I am learning) where I am joining three tables together to display the results of city, county, and state. It works great but I would like for it to not display the duplicates. What is the best way to go about that?

Lake Mills Winnebago Iowa
Lake Mills Jefferson Wisconsin
Madison Dane Wisconsin
Madison Dane Wisconsin
Madison Dane Wisconsin
Middleton Dane Wisconsin
Oakland Alameda California
Orlando Orange County Florida

So instead of showing every madison it would only display once assuming that it the same county and state

$sql = "SELECT city.city, county.county, state.state FROM city INNER JOIN county ON city.city_id=county.county_id INNER JOIN state ON city.city_id=state.state_id ORDER BY city.city";

How is the data listed in the tables?

There are duplicates in the tables

I had the same thought you may have duplicate entries in the table.

then use GROUP BY at the end of the query

Sponsor our Newsletter | Privacy Policy | Terms of Service