Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get odd numbered characters in a string using SQL

I am playing with some encrypted data and I need to get the odd numbered characters from a string and populate into a column:

abcedfgh

to

acdg

Is it really possible to do it in SQL? I tried googling on this but couldn't find any search results.

like image 687
Teja Avatar asked Apr 18 '12 17:04

Teja


1 Answers

SELECT REGEXP_REPLACE(mycolumn, '(.).', '\1')
FROM   mytable
like image 95
Quassnoi Avatar answered Nov 20 '22 17:11

Quassnoi