gpt4 book ai didi

mysql - 如果 id 不为空,则对 mysql 进行分组

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

我有这个数据

id | id_att | name |
1 | Null | jane |
2 | Null | kol |
3 | 1 | der |
3 | 1 | der |
3 | 2 | sol |

我想像这样显示我的数据

 id | id_att | name |
1 | Null | jane |
2 | Null | kol |
3 | 1 | der |
3 | 2 | sol |

如果 id_att != null ,如何对数据进行分组?

最佳答案

我认为你只需要一个SELECT DISTINCT在这里:

SELECT DISTINCT
id,
id_att
name
FROM yourTable;

NULL 在这里的处理方式与任何其他非 NULL 值相同。

关于mysql - 如果 id 不为空,则对 mysql 进行分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55178587/

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