Get unique values of SQL table and echo with PHP

I have a MySQL table with over 200 values. One of the columns on my table is 'date'. Out of all 200 values there are only 5 unique dates.

How can I list out the unique values of the dates and echo them with php. e.g. not getting back 200 instances of dates but just 5.

Answers


Use DISTINCT

SELECT DISTINCT `date` FROM `tablename`....

SELECT myDate FROM myTable GROUP BY myDate

Or...

SELECT DISTINCT myDate FROM myTable

DISTINCT is a nice short hand, but if you ever then want to make use of the query for other purposes, if often constrains you a bit too much. So I prefer the GROUP BY version.


Need Your Help

Google API Client GTMHTTPUploadFetcher duplicated

ios objective-c cocoapods google-api-client

I'm creating a cocoapod. To .podspec I've added the line:

Modifying the interface used for WebChannelFactory

c# .net web-services interface webchannelfactory

If I have a Server/Client application that both reference the same DLL which contains interfaces used for a REST server and for the WebChannelFactory to reference the web server, what would happen to