我需要能够在此选择查询中对来自Aus_Postcodes的邮政编码进行分组,因为正在发生的是要约正在循环。
当前查询:
SELECT approved_business.*,
business_stores.*,
group_concat(offer ORDER BY offer ASC SEPARATOR ',') as offers,
Aus_Postcodes.state as AusState
FROM approved_business,
business_stores,
Real_Cash_Offers,
Aus_Postcodes
WHERE approved_business.id = business_stores.business_id AND
Real_Cash_Offers.business_id = approved_business.id AND
Real_Cash_Offers.storeid = business_stores.storeid AND
business_stores.postcode = Aus_Postcodes.postcode AND
approved_business.id = '1288'
GROUP BY approved_business.id
LIMIT 1
以下是示例输出,我已将其编码为JSON,因为这是我们系统使用的。
[{"id":"1288","tradingname":"Loretta Adams Bridal & Evening Wear","listed":"2012-01-26 19:26:24","pictureurl":"","business_id":"1288","storeid":"1","phone":"6139379210","street":"266 Keilor Rd","suburb":"Essendon North","state":"1","postcode":"3041","discription":"","offers":"1000|70,1000|70,1000|70,300|15,300|15,300|15,500|30,500|30,500|30","AusState":"VIC,VIC,VIC,VIC,VIC,VIC,VIC,VIC,VIC"}]
答案 0 :(得分:1)
将group_concat(offer ORDER BY offer ASC SEPARATOR ',') as offers
更改为group_concat(DISTINCT offer ORDER BY offer ASC SEPARATOR ',') as offers
。