I have a mysql database table where there is an email column which can contain up to two emails separated by an semicolon. What i want to achieve is write the second email address in the email field into another column email2 This is what I tried so far without success:
UPDATE user AS u
SET email2 = (SELECT SUBSTRING_INDEX(email, ';', -1)
FROM user
WHERE user.id=u.id)
WHERE username LIKE "%;%"
When searching for this problems there were some solutions unsing a second subquery within the subquery but none of them really matched my problem.
If anybody has a solution please post it. I have been stuck for at leas 2 hours.
Thank you very much.
No need to complicate your life :
and to clean first column in same query