我有一個SQL查詢,如:返回的行之外凡在條件
select gift.id as giftId, gift.title, count(vouchercode.id) as stock
from gift
inner join vouchertemplate
left join vouchercode
on gift.voucherTemplate = vouchertemplate.id
and vouchertemplate.id = vouchercode.template
and vouchercode.given = 0
and gift.id in (5, 6, 7)
group by gift.id
我希望所有行有gift.id
是的5,6,7
一個,但我得到一排4
了。這是爲什麼?