I want to fetch and display a limited amount of questions that hasn't been answered yet by the logged in user only.
I already have this block of code, but I can't seem to find out how to select it distinctly for a certain logged in user.
SELECT
a.*
FROM
questions as a
LEFT JOIN
questions_answers as b
ON (a.q_id = b.q_id)
WHERE
b.q_id IS NULL
AND b.user_id = 2
ORDER BY
RAND() LIMIT 10
assuming "2" is a sample user ID of the logged in user.
The "AND b.user_id = 2"
is where I'm stuck.
I'll appreciate any help.
UPDATE: Here's the table structure
Questions Table
q_id
question
Questions_Answers Table
ans_id
q_id
user_id
UPDATE: I have already answered this question and added it below. Thank you to everyone who suggested. I'll take your advice seriously as well. I'll appreciate it if you will upvote my answer if you have tried it and get what I meant. :)