MySQL Forums
Forum List  »  Newbie

Re: Strange result from DELETE query - can anyone explain?!
Posted by: Rick James
Date: March 20, 2009 10:56PM

I suggest you get irritated with the authors of the C language (and probably some older languages). In that, there is no Boolean type. Instead by convention and by how IF worked, 0 means FALSE and anything else means TRUE. There are a number of things in MySQL that mimic C, whether we like it or not.

And the other direction...
SELECT SUM(x=y) FROM tbl;
will count how many rows have x and y the same. This is because x=y is boolean, but boolean can be treated as 0 or 1.
That's less clumsy than
SUM(if(x=y, 1, 0))
Well, at least fewer keystrokes.

Options: ReplyQuote




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.