Skip to content

Instantly share code, notes, and snippets.

@rafaeltedesco
Created November 17, 2022 16:45
Show Gist options
  • Select an option

  • Save rafaeltedesco/267931a96b40f659f6c386eeec396cd2 to your computer and use it in GitHub Desktop.

Select an option

Save rafaeltedesco/267931a96b40f659f6c386eeec396cd2 to your computer and use it in GitHub Desktop.
Change row value When match a specific condition using CASE in mySQL
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