regex - MySQL - How to concatenate columns that contain at least one alphabetic character -
i have mysql table 4 varchar columns, in cases these columns can contain number. have concatenate single string columns contain @ least 1 character , ignore columns containing numbers.
example
aa + 88 + po + a4 will result aapoa4
a3a + ww + 11 + ewd will result a3awwewd
so may @ problem concatenation of columns if not match ^\d+$
regular expression or empty string otherwise. may find more documentation on regexp, concat , case in mysql docs, below there code, may lead want achieve:
select concat( case when regexp '^[[:digit:]]+$' '' else end, case when b regexp '^[[:digit:]]+$' '' else b end, case when c regexp '^[[:digit:]]+$' '' else c end, case when d regexp '^[[:digit:]]+$' '' else d end) result your_table;
of course may use not regexp
instead, me it's clearer way.
Comments
Post a Comment