Reputation: 11812
Hello I have a table has some info like this
id | message
1 | x:something
2 | y:something else
3 | z:something else too
4 | x:something else too
5 | y:something else too
6 | z:something else too
Is it possible to select (x,y,z) with no duplicate, but the length of x,y,z is n't always the same, but there will always be a (:) at the end of that string.
Is that possible in mysql ?
Upvotes: 0
Views: 47
Reputation: 115550
SELECT DISTINCT
SUBSTRING_INDEX(field, ':', 1) AS strippedField
FROM tableX
Upvotes: 0
Reputation: 16677
yes - you can select where the SUBSTR
is what you want to match on.
or possibly use REGEX
to match the patterns...
Upvotes: 2