I have two table one is random_questions and another is personal_questions,Ii want to check copy_id column in personal_questions where personal_questions.question_to = current_session_user
and personal_question.copy_id = random_question.id
....
Here is my code :
$session_user = $_SESSION['user_id'];
$sql = mysqli_query($con, "SELECT DISTINCT random_questions.id AS id, random_questions.question_by_id AS question_by_id, random_questions.question AS question, random_questions.total_answers AS answers FROM random_questions INNER JOIN personal_questions WHERE (random_questions.total_answers != '8') OR (personal_questions.question_to != '$session_user' AND personal_questions.copy_id != random_questions.id)");
I am not getting the results properly, if personal_questions's copy_id is equals to any of random_questions's id then results repeats automatically. I hope you understand. Help please.