MySQL Group By 最多特定字符串字符

发布于 2024-12-26 10:04:58 字数 265 浏览 2 评论 0原文

我目前正在开发一个项目,其中有几个字符串可能以不同的消息开头,但字符串中的某处将包含 :.

例如该字段可能包括

尝试登录未知的用户名/密码。用户:admin 失败

添加用户帐户。 MySQL 错误:某些我的 sql 错误未知

用户名/密码尝试登录。用户:管理员

基本上我想将字段分组到:符号,例如尝试登录未知的用户名/密码。用户:将被分组为 1 个条目。

感谢您提供的任何帮助。

I am currently working on a project where I have several string that may start with different message but somewhere in the string will contain a :.

For example the field may include

Unknown username/password attempted to login. User: admin Failed to

add user account. MySQL Error: certain my sql error Unknown

username/password attempted to login. User: administrator

Basically I want to group the fields together up to the : sign e.g. Unknown username/password attempted to login. User: would be grouped as 1 entry.

Thanks for any help you can provide.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落叶缤纷 2025-01-02 10:04:58

试试这个...

SELECT msg1,wholemsg FROM 
 (SELECT SUBSTRING_INDEX(message, ':', 1) AS msg1, message as wholemsg FROM <your table>
  WHERE <your condition>)
GROUP BY msg1

Try this...

SELECT msg1,wholemsg FROM 
 (SELECT SUBSTRING_INDEX(message, ':', 1) AS msg1, message as wholemsg FROM <your table>
  WHERE <your condition>)
GROUP BY msg1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文