Page 1 of 1

Selecting unique records from database table

Posted: Thu Jun 08, 2006 2:28 pm
by michlcamp
I have a data table called 'orders' where customer history is posted and want to pull only unique email address from the table.

I'm starting with query:

Code: Select all

$sql="SELECT email FROM orders ORDER  ASC";
do I use the 'unique' or operator?

thanks in advance...learning slowly but sure...
mc

Posted: Thu Jun 08, 2006 2:34 pm
by feyd
DISTINCT keyword is what you are looking for.

Posted: Thu Jun 08, 2006 2:34 pm
by janson0
I think you can do something like:

Code: Select all

$sql = SELECT DISTINCT email FROM orders;
Try that

Good luck!
-Michael