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)
>
>
>Hello,
>
>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.
>
>Thanks.

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 ...

---------------------------------------------------------------------
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