Re: Problems with a subquery
I find it difficult to understand this query of yours
(although, I'm learning SQL for only a few weeks so it must be it :)
but explain this please:
( SELECT DISTINCT t2.connected_id
*FROM connections as t1, connections as t2
WHERE ( t1.connectee_id = 1 ) AND
**( t1.connected_id = t2.connectee_id ) )
*here, you are usig operator AS to make to tables (t1,t2) from table
connection...
** and still you compare theirs connected_id-s
aren't those, always, the same values?!
those are copys, right?
and in the first subquery...
( SELECT DISTINCT t1.connected_id
FROM connections as t1
WHERE
( t1.connectee_id = 1 ) )
you are just looking for id-s that equal 1?
I would find it much easyer (my-spelling-bad-here?) to make just one query.
Something like:
SELECT users.*
FROM users JOIN connections
ON id=connetee_id
WHERE connectee_id = 1
But again, I can't really tell what is it that you are exactly tryin to
do...
(sorry for replying on your email the first time)
|