是否可以从group_concat mysql中删除1个记录或最大(ID)
我必须删除/跳过group_concat mysql中的第一个记录或最大ID。 这是查询
select email, group_concat(id order by id desc) as id
from api_admin.external_user
group by email
having count(1) > 1;
I have to remove/skip the 1st records or max id in group_concat MYSQL.
Here is query
select email, group_concat(id order by id desc) as id
from api_admin.external_user
group by email
having count(1) > 1;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来是子查询方法:
Looks as sub-query approach:
SQL online environment
您的
group_concat()
返回一个字符串,该字符串是至少2个ID的逗号分隔列表(因为 ake 条款中的条件)排序。您可以使用函数 ) 在第一个逗号之后获取返回的字符串的一部分:
请参阅 demo 。
Your
GROUP_CONCAT()
returns a string which is a comma separated list of at least 2 ids (because of the condition in theHAVING
clause) sorted descending.You can use the function
SUBSTRING_INDEX()
to get the part of the returned string after the first comma:See the demo.