Re: Select distinct field won't return distinct value
| From: | Brad Bonkoski | Date: | Tue, 06 Jun 2006 15:16:01 +0000 |
| Subject: | Re: Select distinct field won't return distinct value | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42006@lists.php.net to get a copy of this message | ||
Perhaps you should fix your data model...
but with your current set up, try:
select cus_name, cus_id from customers group by cus_name order by cus_name asc
-Brad
Mohamed Yusuf wrote:
I want select distinct field and return value of that field, but I have problem which is: select distinct returns duplicate value. eg, I wan select distinct customer name and id from the customer table. one customer may have different cus_ids since cus_ids are auto increment and depend on the purchased items. so what I want is to select distinct customer name so that I can print customer name and customer id once. here is algorithm; select distinct cus_name, cus_id from customers order by cus_name asc While row is not empty do{ echo"<a href=\"page?cus=cus_id\">costomer name</a><br />"; }