select l.b, r.a = l.b from tab l join tab r on l.a = r.b where l.a = 1 ;
seems to produce the result you want
Gabriel B. [EMAIL PROTECTED]
29/03/2005 09:30
Please respond to
Gabriel B. [EMAIL PROTECTED]
To
mysql@lists.mysql.com
cc
Subject
help with a mutuality check (good query exercise :)
I got stuck in this one, and i belive there's a solution, i just don't
happen to see it.
i have a table with conections between itens. something like
+---+---+
| A | B |
+---+---+
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 2 | 1 |
+---+---+
i'm trying to solve with one query a way to get all of the relations
with 1 on the A colum but having another field, telling me if the
relation is mutual. something that would return
+---++
| B | mutual |
+---++
| 2 |1|
| 3 |0|
| 4 |0|
+---++
Can you think of anything that doesn't involve some big temporary
tables or one extra query for every row found on the first one?
,
Gabriel
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]