[PHP] Creating A Unique List With Table Query

2009-02-10 Thread revDAVE
Newbie question

Hi Folks,

I would like to be able to query a table, and return only the unique values
from a particular field. For example: to get all contents from the category
field from the contacts table:

Query = 

SELECT Category FROM contacts

But this will produce many duplicates.

Question : How do I filter the query to only produce unique values?
 
I was looking at: array_unique but I am not sure how to implement this in a
MYSql table query

Any help would be appreciated - thanks Dave



--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating A Unique List With Table Query

2009-02-10 Thread Andrew Ballard
On Tue, Feb 10, 2009 at 2:41 PM, revDAVE c...@hosting4days.com wrote:
 Newbie question

 Hi Folks,

 I would like to be able to query a table, and return only the unique values
 from a particular field. For example: to get all contents from the category
 field from the contacts table:

 Query = 

 SELECT Category FROM contacts

 But this will produce many duplicates.

 Question : How do I filter the query to only produce unique values?

 I was looking at: array_unique but I am not sure how to implement this in a
 MYSql table query

 Any help would be appreciated - thanks Dave



 --
 Thanks - RevDave
 Cool @ hosting4days . com
 [db-lists 09]



SELECT DISTINCT Category FROM contacts

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating A Unique List With Table Query

2009-02-10 Thread Per Jessen
revDAVE wrote:

 Newbie question
 
 Hi Folks,
 
 I would like to be able to query a table, and return only the unique
 values from a particular field. For example: to get all contents from
 the category field from the contacts table:
 
 Query = 
 
 SELECT Category FROM contacts
 
 But this will produce many duplicates.
 
 Question : How do I filter the query to only produce unique values?

SELECT DISTINCT Category FROM contacts



-- 
Per Jessen, Zürich (1.6°C)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [Bulk] [PHP] Creating A Unique List With Table Query

2009-02-10 Thread Stephen

revDAVE wrote:

I would like to be able to query a table, and return only the unique values
from a particular field. For example: to get all contents from the category
field from the contacts table:

Query = 

SELECT Category FROM contacts

But this will produce many duplicates.

Question : How do I filter the query to only produce unique values?
 
  

Check out the DISTINCT keyword in the SELECT documentation.

Also, do you have a Category table?

Stephen

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating A Unique List With Table Query

2009-02-10 Thread revDAVE
On 2/10/2009 11:45 AM, Andrew Ballard aball...@gmail.com wrote:

 SELECT DISTINCT Category FROM contacts

Thanks folks - that was perfect!


On 2/10/2009 11:46 AM, Stephen stephe...@rogers.com wrote:

 Also, do you have a Category table?
 
No Stephen I don't.



--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php