I have a query for a news feed on my website that selects all of the posts from users where the logged in user has a relationship (following) with the user that posted the post. Sounds confusing, but here is my query:
SELECT DISTINCT *
FROM posts a
LEFT JOIN relations b
ON a.user_id = b.user2
WHERE b.user1 = $user_id AND
b.status IN (1) OR a.user_id = $user_id
ORDER BY a.post_id DESC LIMIT 300
Now, if the user has a filter set then the posts need to be filtered. The parameters are set in an array, but I am not sure how to set a condition in my query to test against the array I have created. How do I structure my WHERE clause? I am testing a.tag
The array containing the parameters: $array
SELECT DISTINCT *
FROM posts a
LEFT JOIN relations b
ON a.user_id = b.user2
WHERE b.user1 = $user_id AND
What I need help with:
a.tag IN ARRAY $array AND
b.status IN (1) OR a.user_id = $user_id
ORDER BY a.post_id DESC LIMIT 300
Thanks!