List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 12 2002 9:50pm
Subject:Re: FW: questions about IF(expr1,expr2,expr3)
View as plain text  
At 14:37 -0700 9/12/02, Norris, Joseph wrote:
>-----Original Message-----
>From: Norris, Joseph
>Sent: Thursday, September 12, 2002 12:39 PM
>To: Mysql_List (E-mail)
>Subject: questions about IF(expr1,expr2,expr3)
>Can any one give me some examples of how they have used this function in a
>practical way?  I would like to get a better understanding of how it can be
>used in a select.

One common use is to detect divide-by-zero situations, so that you
can return a value other than NULL:

SELECT IF(at_bats=0,0,hits/at_bats) AS batting_average ...
FW: questions about IF(expr1,expr2,expr3)Joseph Norris13 Sep
Re: FW: questions about IF(expr1,expr2,expr3)Paul DuBois13 Sep