please help mi relating to following mysql query, I have a table main with like below:
id phone phone2
======================================
1 98998 | 58877
2 98998 | 58877
3 98998
i want to update phone2 through phone column and trying to used following subquery but i didnt got the desired result please help to got the result if it is possible:
update main a
set a.phone2 = (SELECT substring_index(b.phone,'|',-1)
FROM main b
where b.phone like '%|%' and where a.id=b.id)