Welcome to WebmasterWorld Guest from 54.167.82.170

Forum Moderators: open

Message Too Old, No Replies

Order and Match

Do not envision "how to"

     

henry0

4:32 pm on Mar 10, 2011 (gmt 0)

WebmasterWorld Senior Member henry0 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I cannot come with a concept
Case:
Table with many rows, among fields are A, B, C,
each are int and contain a value from 1 to 5
example id 333 when ordered by int value comes with a result aqual at B, C, A
and here is my quandary how could I match/select all rows where the same result B, C, A as id 333 exists?

I mean doing it in a consise way and not resource "gobling".

thanks

henry0

6:46 pm on Mar 10, 2011 (gmt 0)

WebmasterWorld Senior Member henry0 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



This an "ugly" and not clever nested query
so how avoiding it?

$result = $db->query("
select
a, b, c, username from my_table
where id='333'
");
while ($row=$db->fetch_array($result) )
{
$u_name=$row['username'];
$a=$row['a'];
$b=$row['b'];
$c=$row['c'];

$result2 = $db->query("
select
a, b, c, username from my_table
where username !='$u_name' AND a ='$a' AND b='$b' AND c='$c'
");
while ($row=$db->fetch_array($result2) )
{
$username=$row['username'];
echo"UN: $username";
}
}
<edit>Typo</edit>

henry0

1:38 pm on Mar 11, 2011 (gmt 0)

WebmasterWorld Senior Member henry0 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Mods: Since no one had a shot at it
please, move this thread to PHP forum
Perhaps, I should have been there instead of DB forum
thanks
 

Featured Threads

Hot Threads This Week

Hot Threads This Month