Page 1 of 1

SELECT DISTINCT..... but not quite as simple as that!

Posted: Mon Jan 05, 2009 6:33 am
by simonmlewis

Code: Select all

$result = mysql_query ("
SELECT * FROM matterusersrights 
INNER JOIN matterdata ON matterdata.clientcode = matterusersrights.clientcode 
WHERE matterusersrights.userid = $cookieid");
while ($row = mysql_fetch_object($result)) 
{
echo "<img src='images/icon_arrow.gif' />$row->persondealing<br/>";
}
    mysql_free_result($result);
    mysql_close($sqlconn);
I need to produce $row->persondealing as a Distinct value, as there will be more than one entry of any name.

Everything in the mysql_query is essential.
Anyone know how to get this to be a distinct result?

Simon

Re: SELECT DISTINCT..... but not quite as simple as that!

Posted: Mon Jan 05, 2009 7:43 am
by VladSun
I'm not sure but it seems you need a GROUP BY user_id.

Re: SELECT DISTINCT..... but not quite as simple as that!

Posted: Mon Jan 05, 2009 7:46 am
by simonmlewis
Perfect - and I cannot believe I didn't think of it.

Many thanks for the quick and perfect resolution!