$query = "SELECT a.value1,b.value2,a.category
FROM sale_villa as a
left join sale_land as b on a.area = b.area
WHERE a.area='$area'
AND b.category BETWEEN '$from_date' AND '$to_date' ";
使用内连接时出现重复的行..
value1 value2
3000000 45000000
4900000 45000000
80000000 45000000
3000000 5000000
4900000 5000000
80000000 5000000
3000000 50000000
4900000 50000000
80000000 50000000
实际上我必须得到......
value1 value2
3000000 45000000
4900000 45000000
80000000 45000000
sale_villa
category
2015-02-01
2015-02-02
2015-02-03
sale_land
category
2015-02-01
2015-02-02
2015-02-03
2015-02-04
答案 0 :(得分:-1)
尝试INNER JOIN而不是左连接和GROUP BY a.value1