Reversing column values in mysql command line
- by user94154
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