trrrrrrm
trrrrrrm

Reputation: 11812

Mysql : is it possible to select those values

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

Answers (2)

ypercubeᵀᴹ
ypercubeᵀᴹ

Reputation: 115550

SELECT DISTINCT
    SUBSTRING_INDEX(field, ':', 1) AS strippedField
FROM tableX

Upvotes: 0

Randy
Randy

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

Related Questions