Page 1 of 1

simple query question

Posted: Wed Jan 09, 2008 7:55 am
by speedy33417
I have a query where I want to get the value of address_id from a table. address_id is not the primary_key and is not unique.

Code: Select all

$sql = "SELECT address_id FROM thistable WHERE date > '$searchDate'";
A query like above will result in values like so:

1
12
45
12
25
25
45

Is it possible to get the values only once. Like so:
1
12
45
25

Thx.

Posted: Wed Jan 09, 2008 7:57 am
by superdezign
You could use the DISTINCT keyword.

Code: Select all

select distinct `address_id` ...

Re: simple query question

Posted: Sun Jan 13, 2008 7:07 pm
by jimthunderbird
or using the group by statement, but i think select distinct might be faster