Hi,
Please help me with a query. I looked in the documentation w/o success.
Consider this table:
mysql> SELECT receiver_id, associate_of, user_name FROM receivers;
+-------------+--------------+-------------+
| receiver_id | associate_of | user_name |
+-------------+--------------+-------------+
| 1 | 0 | arnold |
| 2 | 0 | barney |
| 3 | 0 | cecilia |
| 4 | 2 | diana |
| 5 | 2 | elmer |
| 6 | 3 | fred |
+-------------+--------------+-------------+
6 rows in set (0.00 sec)
It is a recursive table design, meaning that a person can have a boss. The
boss' id is stored in the associate_of column. Eg. elmer is barney's
associate, barney is boss of elmer, and diana
Let's say I only know the user_name 'barney', and I would like to select
all his associates.
I tried a subquery, as it was most logical:
SELECT receiver_id, associate_of, user_name FROM receivers WHERE
associate_of IN (SELECT receiver_id FROM receivers where user_name='barney');
But that returned an error. Then I tried this:
SELECT receiver_id, associate_of, user_name FROM receivers where
associate_of=user_name='barney';
but this gave me a bad recordset...
Also, is this a legal expr.? What does it do? associate_of=(user_name='barney')
How about: (associate_of=user_name)='barney'
Any help is appreciated. Also, if someone could point me to the right
section in the on-line doc. I did not find stuff on operator precedence or
more than one '=' signs in the same expression.
Thanks in advance.
Yours,
Balazs
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php