Bill,

>SELECT @neededStep := 10;
>SELECT @startOfCenter := 7;
>SELECT @returnData :=
>IF(@neededStep <= @startOfCenter,
>     CONCAT(@neededStep, ' <= ', @startOfCenter),
>     CONCAT(@neededStep, ' > ', @startOfCenter)
>    );

>In the above example @returnData ends up being '10 <= 7', but when @neededStep >is less than 10 the expected results are found. (could this be because @neededStep
>is stored as text and not a number?)

In 5.0.10, @returndata is '10 > 7';

PB

-----

Bill Dodson wrote:

I am using version 4.0.12-nt on a Windows 2000 machine.

I have noticed some difference in the way SET and SELECT create variables. The following statements do not work the way I would expect.

SELECT @neededStep := 10;
SELECT @startOfCenter := 7;
SELECT @returnData :=
IF(@neededStep <= @startOfCenter,
CONCAT(@neededStep, ' <= ', @startOfCenter),
CONCAT(@neededStep, ' > ', @startOfCenter)
);

In the above example @returnData ends up being '10 <= 7', but when @neededStep is less than 10 the expected results are found. (could this be because @neededStep is stored as text and not a number?)

In the next example @returnData ends up being '10 > 7', as expected. This seems to work for all values of @neededStep I have tested.

SET @neededStep := 10;
SET @startOfCenter := 7;
SELECT @returnData :=
IF(@neededStep <= @startOfCenter,
CONCAT(@neededStep, ' <= ', @startOfCenter),
CONCAT(@neededStep, ' > ', @startOfCenter)
);

It would seem that SET is a better way to create variables from constant values, but I would like to understand why. Does anybody know what is happening here?

Thanks for your time!
bill



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to