Skip to content

Instantly share code, notes, and snippets.

@Krknv
Last active February 8, 2018 09:26
Show Gist options
  • Save Krknv/058041c5dd1ed56d9b04b67a78c77003 to your computer and use it in GitHub Desktop.
Save Krknv/058041c5dd1ed56d9b04b67a78c77003 to your computer and use it in GitHub Desktop.

PDO loop for updating multiple rows

UPDATE website
    SET http_code = CASE id_website
        WHEN 1 THEN 200
        WHEN 2 THEN 201
        WHEN 3 THEN 202
    END,
    link_exists = CASE id_website
        WHEN 1 THEN 1
        WHEN 2 THEN 2
        WHEN 3 THEN 3
    END
WHERE id_website IN (1,2,3)

https://stackoverflow.com/a/31188205/2618535

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment