1つにしたい2つのクエリがあります。
1位:
SELECT
poll_questions.id,
poll_questions.question,
poll_questions.qmore,
poll_questions.total_votes,
poll_questions.active,
poll_questions.created_at,
poll_answers.answer,
poll_answers.votes,
poll_answers.id AS answer_id,
poll_photos.photo_name_a,
users.username
FROM poll_questions
LEFT JOIN (poll_answers, poll_photos)
ON (poll_answers.question_id = poll_questions.id AND
poll_photos.question_id = poll_questions.id
)
LEFT JOIN users ON poll_questions.author = users.id
WHERE poll_questions.active = 1
ORDER BY poll_questions.created_at DESC
LIMIT {$per_page} OFFSET {$offset}
2番目:
SELECT vote_history_raw.vote
FROM vote_history_raw
WHERE vote_history_raw.user_id = {$user_id}
最初のクエリのユーザーは作成者であり、2 番目のクエリでは投票者であることに注意してください。
ご協力いただきありがとうございます!