Skip to content

Instantly share code, notes, and snippets.

@kauhat
Created January 11, 2018 12:33
Show Gist options
  • Save kauhat/3c8e7eb2014b506b5e3c9cce39210400 to your computer and use it in GitHub Desktop.
Save kauhat/3c8e7eb2014b506b5e3c9cce39210400 to your computer and use it in GitHub Desktop.
Using a CASE/WHEN/THEN/ELSE statement within an UPDATE query.
UPDATE `organisations`
SET `description` = CASE id
WHEN 1 THEN 'something'
WHEN 2 THEN 'something else'
WHEN 3 THEN 'we\'re on the third record still'
WHEN 5 THEN 'we\'ve jumped to record five'
WHEN 6 THEN '...'
ELSE NULL
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment