Hi.

WHERE expects a boolean expression, but 

user_num+"AL011-33"

is no boolean expression. MySQL therefore assumes that the result of
the expression should be considered as boolean value. Analogous to C
and similar languages, it assumes the expression to be 'false', if it
is zero (numbers) or empty (strings). Else, it is considered 'true'.
Therefore the above expression is equivalent to

WHERE user_num+"AL011-33" != 0

as '+' is integer addition. It forces conversion of user_num and
"AL011-33" to numbers. I guess atol() (or some equivalence) is used
and therefore the string is converted, using all numbers from the left
to right, until the first non-numerical characters is met and the
conversion simply stops, returning the current value. E.g.

33-110AL -> 33 -> true
000110AL -> 110 -> true
AL011-33 -> 0 -> false
000AL-33 -> 0 -> false

Therefore "AL011-33" converts to 0 (it starts with a non-number) and
doesn't add to the sum of '+'. So it boils down to the question
whether user_num converts to a number differnt from 0. This is the
case, if user_num starts with a number (and not a character), and the
numbers are not only '0's.

This results in the obversation, that only user_num which start with a
number have been deleted.

Bye,

        Benjamin.

On Tue, Feb 20, 2001 at 12:14:02AM +0100, [EMAIL PROTECTED] wrote:
> i guess the calculation returns a result (ie: whether it's successfull or
> not), so '1-1' evaluates true; but 1-A evaluates false because A is not a
> number so you can't calculate on it.
> 
> So in your case, this would be:
> where user_num+"AL011-33"
> if user_num='0':
>   where '0'="%any%"; /// returns True;
> if user_num='Xxx':
>  where NAN= any...; /// returns False
> 
> makes some sense..if user_num is valid to calculate with %any% other value,
> comparison returns true, elsewise false.
> 
> 
> ----- Original Message -----
> From: "Jordan" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: 2001-02-19 11:29 PM
> Subject: + or - in place of = does what???
> 
> 
> > First time here, sorry if this is too much of a novice question to get
> > answered...
> >
> > I just sent the command:
> >
> > DELETE FROM users WHERE user_num+"AL011-33";
> >
> > by accident (I meant to use an "=" not the "+").  It killed 81 rows.  I
> > restored the data, but I couldn't find anything in the docs about what
> that
> > command actually did.
> >
> > After restoring the data, I ran the command again (substituting SELECT for
> > DELETE) and it looks like it gives me all the users that have user_num
> that
> > start with a number rather than a letter.  I got the same results
> > regardless of whether I sent the command with a "-" or a "+".  What gives?

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to