Do you want to have a floor of zero?
UPDATE topic SET liked = liked - 1 WHERE id='$id' AND liked > 0;
If you need negative numbers, you need a SIGNED datatype . However, you need to know the limitations to avoid errors. See "Out of Range and Overflow Processing"
So, the assumption that I liked it is changed to SIGNED TINYINT ...
UPDATE topic SET liked = liked - 1 WHERE id='$id' AND liked > -128;
source share