Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to filter result Select SQL not double?

Status
Not open for further replies.

warik

Programmer
Joined
Jun 28, 2002
Messages
169
Location
ID
Dear all,

I have problem for output sql query become double, how to make it show only 1 even there are more than 1 at record table.

Maybe filter the output or something else ?

e.g.

table name=data

number | owner
11 | jon
30 | ane
14 | jack
12 | jon
40 | ken
15 | susi
55 | don

the sql :

$query = &quot;SELECT * FROM data WHERE number < 20&quot;;
$result = mysql_query($query);

if ($row = mysql_fetch_array($result))
{
do
{
echo &quot;$row[0]<br>&quot;;
} while ($row = mysql_fetch_array ($result));
}


The result will be :

jon
jack
jon
susi

There are 2 jon.

What I need just only one result if the same like this :

jon
jack
susi



Pls help me

Thank's in advance
 
how about selecting only the name and then using DISTINCT?

like

SELECT DISTINCT name where number<20

or try using GROUP BY name ?

 
Sorry name should be owner.. didn't catch that

Or if you insist on using the php you could create another array and transfer the name one by one, checking each value owner with the second array for same/already transferred value..

 
Nomida, it work as what I need.

I use :

SELECT DISTINCT name FROM data WHERE number<20


Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top