MySQL Forums
Forum List  »  PHP

Re: Enum Toggle
Posted by: Felix Geerinckx
Date: May 17, 2005 08:03AM

�ke Lagercrantz wrote:
> Hey!
>
> I've got a 2 option enum variable, say yes/no.
>
> What I want to do is to toggle this enum with a single push of a button (a single update query).

DROP TABLE IF EXISTS foo;
CREATE TABLE foo (id INT NOT NULL PRIMARY KEY, yn ENUM('y', 'n'));
UPDATE foo SET yn = IF(yn = 'y', 'n', IF(yn = 'n', 'y', yn)) WHERE id = <<some_id>>;

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
May 16, 2005 10:10AM
May 16, 2005 11:28PM
Re: Enum Toggle
May 17, 2005 08:03AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.