【发布时间】:2013-12-20 03:23:37
【问题描述】:
假设这是我的数据库表: id、client_id、order_name
每一个翻倍的订单都在创造新的记录。例如:
1, 1, super-glue
2, 1, super-glue
3, 1, plastic wallet
我如何在单个查询中找到客户订购了多少不同的商品?
所以在这种情况下它会返回 2。
我知道我必须使用SELECT {something in here} WHERE client_id = 1,但我不确定如何计算不同的项目。
【问题讨论】:
-
为什么是 2 而不是 1?请多解释
-
因为买了两件不同名字的东西。
标签: mysql select count where items