sql update – flip value boolean 1-0-1

If we need to toggle on a value, (for 1 to 0 and vice-versa for example), using a update, this is one solution…

UPDATE user SET profile_status = CASE WHEN profile_status = 1 THEN 0 ELSE 1 END WHERE user_id="1";

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.