Created
November 17, 2022 16:45
-
-
Save rafaeltedesco/267931a96b40f659f6c386eeec396cd2 to your computer and use it in GitHub Desktop.
Change row value When match a specific condition using CASE in mySQL
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
| SELECT | |
| new_name, | |
| last_name, | |
| CONCAT(new_name, ' ', last_name) AS full_name | |
| FROM | |
| (SELECT | |
| (CASE | |
| WHEN first_name = 'NICK' THEN 'LINK' | |
| ELSE first_name | |
| END) AS new_name, | |
| last_name | |
| FROM | |
| sakila.actor) AS SUBQ | |
| WHERE | |
| SUBQ.new_name = 'LINK'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment