Created
January 5, 2022 06:58
-
-
Save syn-arch/3b60314f2780ce9b9398e5ae726f3278 to your computer and use it in GitHub Desktop.
mysql update column with value from another table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE tableB | |
INNER JOIN tableA ON tableB.name = tableA.name | |
SET tableB.value = IF(tableA.value > 0, tableA.value, tableB.value) | |
WHERE tableA.name = 'Joe' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment