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

--
Bill Dodson
Parkline, Inc. http://www.parkline.com
phone: 304-586-2113 x149
fax: 304-586-3842
email: [EMAIL PROTECTED]


Email Disclaimer

The information in any email is confidential and may be legally privileged. It 
is intended solely for the addressee. Access to the email message by anyone 
else is unauthorized. If you are not the intended recipient, any disclosure, 
copying, or distribution of the message, or any action or omission taken by you 
in reliance on it, is prohibited and may be unlawful. If you have received an 
email message in error, please notify the sender immediately by email, 
facsimile or telephone and return and/or destroy the original message.

Thank you.


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

Reply via email to