I am trying to select a row with a distinct id, yet return all the fields.
SELECT * DISTINCT(ID) FROM table WHERE ...
I ultimately need the ID, City, State and Zip. How can I get rows that are not duplicate ID’s and return all fields into my mysql_fetch_array?
I have tried the following:
SELECT * DISTINCT(ID) FROM table WHERE ... SELECT DISTINCT ID * FROM table WHERE ... SELECT ID,City,State,Zip DISTINCT ID FROM ... SELECT ID,City,State,Zip DISTINCT(ID) FROM ...
I was reading other questions here and none seem to help. Thanks in advance!
select id, city, state, zip from mytable group by id
Note that this will return an arbitrary address for each
id if there are duplicates.