【发布时间】:2021-07-02 13:27:25
【问题描述】:
我想从 (itemof_shop.idreg_shop) 列中选择 DISTINCT(不同)值,但它不起作用。(mysqli)
select distinct
itemof_shop.idreg_shop,
itemof_shop.id
from
itemof_shop
inner join reg_shop on
itemof_shop.idreg_shop = reg_shop.id_shopOrgi
【问题讨论】:
-
你期待什么结果,你收到什么结果?请提供样本数据。 stackoverflow.com/help/minimal-reproducible-example
-
我收到重复的值。DISTINCT 无效。这个查询带有 DISTINCT 并且没有 DISTINCT 给了我相同的结果
-
@FaisalWahidi 请提供示例数据和所需的输出
-
如果没有样本数据,就无法确定,但是当您使用 DISTINCT 时,它将提供所有返回列的不同列表。由于您在选择列表中有 itemof_shop.Id,并且 id 通常是唯一值,这就是您没有获得 itemof_shop.idreg_shop 的不同列表的原因。从 select 语句中删除 Id 列。
标签: sql select distinct distinct-values