0

我目前正在跨 3 个表执行以下查询;handset,dealtariff:

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,我想将价格最低的关税加入到查询的结果中。

4

1 回答 1

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
于 2013-03-02T07:18:25.283 回答