EDIT:
Here is my table:
[user_friend] table:
[late] table:
Now, let's just say the current user's id is '1', I want to search the table user_friend for all the rows with the user_id of '1' then put all the friend_id all the rows with user_id of '1' in a var or something(Let's just say there 3 rows with the friend_id of 2,3 $ 4 respectively).
Now I want to get the id of the rows in the late table with the user_id of any of the current user's friend's id(For this case it's 2,3 & 4). Hope it helps
UPDATE
If i understand your new info correctly this will select a list of friend_id
's from the user_friend
table where the current user_id
= 1. It will then use this list of friend_id
's to select all those entries from late
where those friend_id
's appear.
SELECT * FROM late WHERE user_id IN (SELECT friend_id FROM user_friend where user_id=1);
You could also achieve the same using table joins. But it isn't as easy to explain.
Original Response Suggest a way of doing this may be to use a WHERE IN (SUB SELECT)
but this may not be the most efficient... it going to depend on your data structure and quantity of data - but you dont provide enough information...
Something like:
SELECT * FROM late WHERE user_id IN (SELECT * FROM user_friends WHERE id IN (1,2,3));
As i said there are most definatley better ways - but more information would help.