Andromedae93 Andromedae93 - 1 month ago 18
MySQL Question

MySQL concat & regex

I'm asking a question about the

concatenation function
and
regex
.
I have a fied (
reference
) which looks like :

FW123
TS76
FWE8E
K987
HT78
FW345


I would like to concatenate all rows which begins by
FW
with
EU
at the end.
So the result must looks like :

FW123EU
TS76
FWE8EEU
K987
HT78
FW345EU


This is my command line :

UPDATE ps2_product
SET `reference` = CONCAT(^FW[A-Z0-9],EU)


It's the first time I handle regex expressions.
The syntax is correct ?

Thank you,

Answer

you can use LIKE :

UPDATE ps2_product t
SET t.`reference` = CONCAT(t.`reference`,'EU')
WHERE t.reference LIKE 'FW%'