select reverse(substring_index(reverse(substring_index('aaaa-bbb-ccc-ddd', '-', 1)), '-', 1));
aaaa
select reverse(substring_index(reverse(substring_index('aaaa-bbb-ccc-ddd', '-', 2)), '-', 1));
bbb
select reverse(substring_index(reverse(substring_index('aaaa-bbb-ccc-ddd', '-', 3)), '-', 1));
ccc
select reverse(substring_index(reverse(substring_index('aaaa-bbb-ccc-ddd', '-', 4)), '-', 1));
ddd
SELECT locationid,
reverse(substring_index(reverse(substring_index(locationid, '-', 1)), '-', 1)),
reverse(substring_index(reverse(substring_index(locationid, '-', 2)), '-', 1)),
reverse(substring_index(reverse(substring_index(locationid, '-', 3)), '-', 1)),
reverse(substring_index(reverse(substring_index(locationid, '-', 4)), '-', 1))
from tb_loc_xy where locationid like '571DCG%';
update tb_loc_xy set
warehouse_code = reverse(substring_index(reverse(substring_index(locationid, '-', 1)), '-', 1)),
zone = reverse(substring_index(reverse(substring_index(locationid, '-', 2)), '-', 1)),
channel = reverse(substring_index(reverse(substring_index(locationid, '-', 3)), '-', 1)),
loc = reverse(substring_index(reverse(substring_index(locationid, '-', 4)), '-', 1))
where locationid like 'CCC%';