MySQl sub query example 2

SELECT
q.questionId,
q.question,
q.questionTopic,
q.questionDate,
q.courseId,
q.customerId,
v.voted_this
FROM
” . $course_database_questions_table_name . ” q
LEFT JOIN
(SELECT questionId voted_this FROM votes WHERE customerId = ‘” . $customer_id . “‘) v
ON
q.questionId = v.voted_this
WHERE
q.courseId = ” . $courseId . ”
ORDER BY q.questionDate DESC

Comments are closed.