SELECT
questions.id,
questions.question_name,
questions.answer,
questions.variant1,
questions.variant2,
questions.variant3,
questions.variant4,
questions.user_id,
questions.city_id,
questions.street_id,
questions.date,
questions.img,
users.login,
city.city_name,
street.street_name,
COUNT(comments.questions_id) as countComment
FROM questions
INNER JOIN users
INNER JOIN city
INNER JOIN street
LEFT JOIN comments
ON questions.user_id = users.id
AND questions.city_id = city.id
AND questions.street_id = street.id
AND comments.questions_id = questions.id
GROUP BY questions.id ORDER BY `date` DESC |