Created
October 25, 2017 11:26
-
-
Save imliam/a2c7fdf1d5a3ccded311dfce0277533e to your computer and use it in GitHub Desktop.
Switch the values between two columns of the same row using a variable.
This file contains 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
/* | |
|-------------------------------------------------------------------------- | |
| Switch Column Values | |
|-------------------------------------------------------------------------- | |
| | |
| Switch the values between two columns of the same row using a variable. | |
| | |
| Assigns a temporary variable "@tmp" to store "columnA", then replaces | |
| the columnA with columnB, then columnB with "@tmp". | |
| | |
*/ | |
UPDATE user SET columnA=@tmp:=columnA, columnA=columnB, columnB=@tmp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment