I want to count the number of different magnets that are in my table.
They´re defined by a string of around 20 elements, of which I´m interested in the first five.
All of them have the same pattern:
mgn##
the word mgn followed by two numbers. I have to specify that the fourth and fifth element are integers, as some of the rows have letters after mgn.
I´ve tried different queries so far, just guessing in the air.
mysql> SELECT DISTINCT(SUBSTRING(magnet, 1, 5)) FROM magcom WHERE magnet LIKE '%mgn\d\d%';
mysql> SELECT DISTINCT(SUBSTRING(magnet, 1, 5)) FROM magcom WHERE magnet LIKE '%mgn##%';
These gives the message empty set.
Any help would be apprciated.