A couple of things concern me - firstly you are using text for the status. Try changing the type of
status
to be an
tinyint
or a
bit
. You can then use the bitwise XOR operator
^
(caret) to "toggle" between the values on each update
INSERT INTO if_exist('id','email','status') VALUES('','myname@yahoo.com',1) ON DUPLICATE KEY UPDATE status = status ^ 1
I.e. on first insert the value of status = 1 (Liked)
On 2nd attempt status will be changed to 0 (Unliked)
On 3rd attempt status will be changed to 1 (Liked, again)