Pregunta

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?

¿Fue útil?

Solución

Use distinct

SELECT DISTINCT state FROM zip_codes 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top