I have a query to get the users friends, and one to get all posts users have posted as statuses, now I need to combine them.
Friends:
SELECT CASE WHEN userID=$session THEN userID2 ELSE userID END AS friendID
FROM friends
WHERE userID=$session OR userID2=$session
then users posts:
SELECT * FROM posts
WHERE toID=fromID AND state='0'
ORDER BY id DESC LIMIT 10
so both work as they should work together. friendID from the first query should equal toID or fromID, it doesn’t matter which since they both need to be the same.
Your second condition for the posts is that they are from friends. So: