Problems with a subquery
Hi,
I have this query that works coorrectly
( SELECT DISTINCT t1.connected_id FROM connections as t1 WHERE
( t1.connectee_id = 1 ) ) UNION ( SELECT DISTINCT t2.connected_id FROM
connections as t1, connections as t2 WHERE ( t1.connectee_id = 1 ) AND
( t1.connected_id = t2.connectee_id ) )
but when i use it as a subquery like this
SELECT * FROM users WHERE id IN ( ( SELECT DISTINCT t1.connected_id
FROM connections as t1 WHERE ( t1.connectee_id = 1 ) ) UNION ( SELECT
DISTINCT t2.connected_id FROM connections as t1, connections as t2
WHERE ( t1.connectee_id = 1 ) AND ( t1.connected_id =
t2.connectee_id ) ) )
i get a syntax error
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'UNION ( SELECT DISTINCT t2.connected_id FROM
connections as t1, connections as t' at line 1
I don't understand what is the problem. How can i get this to work?
Thanks
f.mardini
|