SELECT
`tbl_users`.`email`,
`tbl_questions`.`q_id`,
`tbl_questions`.`question`,
`tbl_questions`.`tags`,
`tbl_questions`.`posted_at`,
SUM(tbl_questions_votes.upvote) AS upvotes,
SUM(tbl_questions_votes.downvote) AS downvotes
FROM
`tbl_users`
INNER JOIN
`tbl_answares`
ON
`tbl_answares`.`user_id` = `tbl_users`.`user_id`
LEFT JOIN
`tbl_questions`
ON
`tbl_questions`.`q_id` = `tbl_answares`.`q_id`
LEFT JOIN
`tbl_questions_votes`
ON
`tbl_questions`.`q_id` = `tbl_questions_votes`.`q_id`
WHERE
`tbl_users`.`user_status` = 1 AND `tbl_answares`.`user_id` = '6'
GROUP BY
`tbl_questions`.`q_id`
ORDER BY
`tbl_questions`.`posted_at`
DESC
Above query is returning email of user that answered the question (another columns are right output) but, i want the email of the user that asked the question.
output: output
Expected Output
`tbl_users`.`email`, // email of user that asked the question
`tbl_questions`.`q_id`,
`tbl_questions`.`question`,
`tbl_questions`.`tags`,
`tbl_questions`.`posted_at`,
SUM(tbl_questions_votes.upvote) AS upvotes,
SUM(tbl_questions_votes.downvote) AS downvotes