Reputation:
I have these rows:
db666405.gallery
db666405.table1
db666405.table2
I want to capture the word after the dot.
How to do with regex in mysql?
I have tried with ^\.
or [.]
, but I did not succeed.
SELECT *
FROM `table`
WHERE `column` REGEXP '^\\.'
Upvotes: 1
Views: 39
Reputation: 3577
To select any columns that have the word Gallery, you can use a
SELECT *
FROM `table`
WHERE `column` LIKE '%gallery%' `
This will return all that have gallery
Upvotes: 0
Reputation: 424973
MySQL regex doesn't "capture" anything. It's for matching only; there is no support for regex replacement in MySQL.
I assume you want to return the part after the dot:
select *, substring(`column`, instr(`column`, '.') + 1) as ext
from `table`
where `column` like '%.?%'
Upvotes: 2