当检索到多个类似记录时,我已经搜索了所有内容,我需要将 1 个字段加在一起。我的查询和结果如下。
这是我的查询:
SELECT m.id as 'id', m.name as 'Merchant Name', c.numStamps as 'Num Stampts on Card', COUNT(c.numStamps) as '# Users with this # Stampts'
FROM Merchants m, Cards c, Stores s
WHERE c.store_id = s.id
AND s.merchant_id = m.id
and c.redeemed = 0
and c.Numstamps>8
and c.datelaststamp > '2011-07-16 07:00:00'
group by m.id, c.numStamps
order by m.name, c.numStamps
这些是结果:
id Merchant Name Stampts UserStampts
391 360 Gourmet Burritos 9 3
391 360 Gourmet Burritos 10 6
我需要结合id
和Merchant Name
。Stampts
没关系,但我需要加在一起UserStampts
。所以我需要回报是:
391 360 Gourmet Burritos 10 9