• Написать 3 sql-запроса к двум таблицам?

    @challenger1401
    1) SELECT t1.MF_ID, count(*)
    FROM `производители` t1
    LEFT JOIN `продукты` t2 ON t1.MF_ID = t2.PD_MFID
    GROUP BY t1.MF_ID
    HAVING count(*)=0

    2) SELECT t1.MF_ID, max(t2.PD_PRICE)
    FROM `производители` t1
    LEFT JOIN `продукты` t2 ON t1.MF_ID = t2.PD_MFID
    GROUP BY t1.MF_ID
    ORDER BY max(t2.PD_PRICE) DESC

    3) SELECT t1.MF_ID, count(*)
    FROM `производители` t1
    LEFT JOIN `продукты` t2 ON t1.MF_ID = t2.PD_MFID
    GROUP BY t1.MF_ID
    ORDER BY count(*) DESC
    LIMIT 2,1
    Ответ написан
    Комментировать