Could you please let me know how write a program to separate 1 to one side and 0 to one side in a binary string in mysql?
example, 101010 to 111000
CodePudding user response:
A simple approach, using REPLACE:
SELECT bin_str,
CONCAT(REPLACE(bin_str, '0', ''), REPLACE(bin_str, '1', '')) AS output
FROM yourTable;
