Question

I have a table of zip codes in my MySQL database. It uses PHPMyAdmin and I'm using PHP code.

The table looks something like this:

zip_codes(id, zip, state)

The problem here is that I want to generate a quick list of the states in this table. However, I don't want a list of 33,000+ states that are 99.9% duplicates(many, many zip codes in each state). I just want to show one Alabama for instance. One Tennessee.

Is it possible to get a recordset like this?

Was it helpful?

Solution

Use distinct

SELECT DISTINCT state FROM zip_codes 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top