我目前正在3个表中执行以下查询; handset
,deal
和tariff
:
SELECT
h.*, d.*, t.* FROM handset h
LEFT JOIN deal d ON h.id = d.handset_id
LEFT JOIN tariff t ON d.tariff_id = t.id
ORDER BY
h.popularity
DESC LIMIT 10
“关税”表格中有一个名为price
的列,我想以最低价格加入所查询结果的关税。
答案 0 :(得分:1)
SELECT
h.*, d.*, t.* FROM handset h
LEFT JOIN deal d ON h.id = d.handset_id
LEFT JOIN tariff t ON d.tariff_id = t.id
where t.price=(select min(price) from tariff)
ORDER BY
h.popularity
DESC LIMIT 10