I have a table posts
with the column published
, which is either 0 (unpublished) or 1 (published).
Say I want to make all the published posts into unpublished posts and all the unpublished posts into published posts.
I know that running
UPDATE posts SET published = '1' WHERE published = '0';
UPDATE posts SET published = '0' WHERE published = '1';
will end up turning all my posts into published posts. How can I run these queries in the mysql command line so that it truly "reverse" the values, as opposed to the mistake outlined above?
Thanks
EDIT: assume the data types are strings. I know ints/bools are a much better way to do this, but I'm working with strings, and changing the schema is not an option.