Reputation: 36205
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.
Upvotes: 0
Views: 1639
Reputation: 1884
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
Upvotes: 4