I have 2 tables "browsers" and "votes". I need all the browsers and only the votes by a vote_ranking and a user_id. Sometimes there is no votes but i still need the browsers. That's the code i wrote:
SELECT browsers.*, votes.*
FROM browsers LEFT JOIN votes ON browsers.app_id = votes.app_id
WHERE vote_ranking = '$ranking' AND user_id = $userid or vote_id IS NULL
The problem is when there is no votes (vote_id IS NULL) the app_id is changed to NULL. But i need to keep the browsers app_id even there's no app_id in votes.
Can i join the table votes only on rows where the're is a vote_id ? Or anything similar to do what i need ?
Thanks