Re: Crappy results from query

From: Date: Wed, 18 Feb 2004 15:30:55 +0000
Subject: Re: Crappy results from query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-178116@lists.php.net to get a copy of this message
Ryan A wrote:
$result=mysql_query("SELECT distinct(order_id),name,status,total FROM
".
$tcname."_h2o LIMIT $limit1, $limit2"); The distinct keyword applies to the whole row. Since you're including other fields that will be different even though the name is the same, MySQL does not consider them duplicate rows. -- Stuart
Hey Stuart, Thanks for replying. So what can I do to make sure I get only order_id distinct? possible? Thanks, -Ryan
SELECT DISTINCT order_id FROM ... Then loop through the results and run another query to find out details of each order. HTH, Mike

« previous php.general (#178116) next »