gpt4 book ai didi

mysql - 根据多列删除重复项

转载 作者:行者123 更新时间:2023-11-29 16:02:35 26 4
gpt4 key购买 nike

我有一个由 (col1,col2,col3) 组成的多个字段主键。不过在添加PK之前,已经添加了很多重复的内容,需要删除。

对于我的 table 来说,如果我有:

Col1 Col2 Col3
---- ---- ----
2 3 3
2 3 3
2 3 4
2 4 null
2 4 null

查询结果应为

 Col1 Col2 Col3
---- ---- ----
2 3 3
2 3 4
2 4 null

只有第三列可以为空。

最佳答案

使用不同

select distinct col1, col2, col3
from tablename

关于mysql - 根据多列删除重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56056390/

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