gpt4 book ai didi

MySQL:从select distinct中选择所有行

转载 作者:行者123 更新时间:2023-11-29 03:20:12 24 4
gpt4 key购买 nike

我想做一个特定的查询

select distinct name 
from tablename

删除重复项。但这只给了我名字。从“从表中选择不同的名称”我希望所有列都返回一个 where 条件:

select * 
from tablename
where value= 1

我试过这个:

select * 
from tablename
where value = 1 and exists (select distinct name
from tablename)

不幸的是,它返回的数据与:

select * 
from tablename
where value = 1

这意味着我的查询存在根本性缺陷。

有人可以帮我解答一下吗?提前谢谢你。

最佳答案

你能试试这个从表名组中按字段2选择字段1、字段2、字段3吗

关于MySQL:从select distinct中选择所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46583499/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com