MySQL在不同的查询中获取最小数量

时间:2015-03-09 18:34:22

标签: mysql

我在这里有这个问题:

SELECT DISTINCT id, name, community, mapLocation, logo FROM `ourCommunity` INNER JOIN readyBuilt ON community = home_community WHERE home_new = "yes" AND isDeleted = 0 AND is_upcoming = 0

并且这会返回7个结果,当我尝试从readyBuilt表中获取每个项目的最低价格时,它只返回1项,而不是7 :(我试过这个MIN(价格)我做错了什么?

1 个答案:

答案 0 :(得分:0)

选择min(price),id,name,community,maplocation where id in( SELECT DISTINCT id FROM ourCommunity INNER JOIN readyBuilt ON community = home_community WHERE home_new =“yes”AND isDeleted = 0 AND is_upcoming = 0)