selecting unique values from a column selecting unique values from a column php php

selecting unique values from a column


Use the DISTINCT operator in MySQL:

SELECT DISTINCT(Date) AS Date FROM buy ORDER BY Date DESC;


use

SELECT DISTINCT Date FROM buy ORDER BY Date

so MySQL removes duplicates

BTW: using explicit column names in SELECT uses less resources in PHP when you're getting a large result from MySQL


Use this query to get values

SELECT * FROM `buy` group by date order by date DESC