I have this simple query:
SELECT
friend_id
FROM
default_friend
WHERE
user_id = 1
And the results are below:
+-----------+
| friend_id |
+-----------+
| 2250 |
| 4901 |
| 7187 |
| 9337 |
| 9843 |
+-----------+
Now I have this query too a bit more complex:
SELECT
friend_id, user_id, approved
FROM
default_friend
WHERE
user_id = 1
AND (friend_id IN (SELECT
friend_id
FROM
default_friend
WHERE
user_id = 1))
AND approved = 0
My question is: will the SELECT into the second query return the same data as the data returned by first query? Meaning friend_id = 2250, 4901, 7187, 9337, 9843 or I need to run the first and the programmatically split the results and build the second one? Also I'll like to know which way is more optimum!
(SELECT friend_id FROM default_friend WHERE user_id = 1)or the similar one return anything else but the four values:(1,2,3,4)– ypercube Aug 17 '12 at 14:35