You could use a CASE statement:

SELECT
        CASE 
        WHEN @exp >= 5 AND @exp <= 10
        THEN vacation + 4
        WHEN @exp >2 AND @exp <5
        THEN vacation + 2
        ELSE vacation
        END

-----Original Message-----
From: sakhiya [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 29, 2004 4:15 PM
To: [EMAIL PROTECTED]
Subject: "if" statement


Hello all,
I'm a newbie and I appreciate any help I can get for
my basic question.
For example,let's say I have a table with fields 
experience, vacation.
I'm doing,
select @exp:=experience from the table
then I do some mathematical calculations with @exp
variable. My question is how do I write statements for
"if @exp >= 5 and @exp <10 then vacation = vacation +
4 else if @exp >2 and @exp < 5 then vacation =
vacation +2".

Thanks in advance for your help.
nishi

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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


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

Reply via email to