这是 C#/Linq:
Fbc_tickets.GroupBy(t => t.Fbt_household_id)
LinqPad 告诉我这正在被翻译成(MySQL):
SELECT t0.fbt_household_id
FROM fbc_ticket AS t0
GROUP BY t0.fbt_household_id
SELECT t0.fbc_ticket_id, t0.fbt_client_id, ...
FROM fbc_ticket AS t0
WHERE ((t0.fbt_household_id IS NULL AND @n0 IS NULL) OR (t0.fbt_household_id = @n0))
-- n0 = [1]
SELECT t0.fbc_ticket_id, t0.fbt_client_id, ...
FROM fbc_ticket AS t0
WHERE ((t0.fbt_household_id IS NULL AND @n0 IS NULL) OR (t0.fbt_household_id = @n0))
-- n0 = [2]
...
为什么它会生成所有这些查询?我期待更类似于的东西
SELECT * FROM fbc_ticket GROUP BY fbt_household_id
就是这样……
fbt_household_id
是无符号整数且不可为空。