0

I want to run sql command only once for update column..

UPDATE article SET published = '1 OR 0' WHERE id = '1'

In above command "1 OR 0" is mean;

If article's published column is 1/true, set 0/false.. If published is 0/false, set 1/true..

What can i do?

Thanks for help..

Bora
  • 10,529
  • 5
  • 43
  • 73

2 Answers2

2
UPDATE article SET published = NOT published WHERE id = '1';
Thomas Kelley
  • 10,187
  • 1
  • 36
  • 43
0

Try to use if() function:

UPDATE article 
SET published = if(published=0,1,0) 
WHERE id = '1';
Robert
  • 25,425
  • 8
  • 67
  • 81