Задать вопрос
  • Как составить запрос MySQL?

    @ko121 Автор вопроса
    Нашел решение сам:

    SELECT
        appeals.id, appeals.text, appeals.answer, appeals.joins, appeals.supports, appeals.dislikes, receivers.code, receivers.name_ru,
        EXISTS(SELECT * FROM joins j WHERE j.appealId = appeals.id and j.autorId = 1) AS isJoined,
        EXISTS(SELECT * FROM supports s WHERE s.appealId = appeals.id and s.autorId = 1) AS isSupported,
        EXISTS(SELECT * FROM dislikes d WHERE d.appealId = appeals.id and d.autorId = 1) AS isDisliked
    FROM appeals
    	LEFT JOIN receivers ON receivers.id = appeals.toId
    WHERE appeals.lang = "ru"
    ORDER BY appeals.id DESC;
    Ответ написан
    Комментировать