<< previous page   --   table of contents   --   next page >>
| | | | | | | |
  • Return to Table of Contents
  • Table of Contents

    1. General Information
    2. MySQL Installation
    3. Tutorial Introduction
    4. Database Administration
    5. MySQL Optimisation
    6. MySQL Language Reference
    7. MySQL Table Types
    8. MySQL APIs
    9. Extending MySQL

    412 MySQL Technical Reference for Version 4.0.3 6.3.1.4  Control Flow Functions IFNULL(expr1,expr2) If expr1 is not NULL, IFNULL() returns expr1, else it returns expr2.  IFNULL() returns a numeric or string value, depending on the context in which it is used: mysql> SELECT IFNULL(1,0); -> 1 mysql> SELECT IFNULL(NULL,10); -> 10 mysql> SELECT IFNULL(1/0,10); -> 10 mysql> SELECT IFNULL(1/0,'yes'); -> 'yes' NULLIF(expr1,expr2) If  expr1 = expr2  is true, return  NULL  else return  expr1.  This is the same as CASE WHEN x = y THEN NULL ELSE x END: mysql> SELECT NULLIF(1,1); -> NULL mysql> SELECT NULLIF(1,2); -> 1 Note that expr1 is evaluated twice in MySQL if the arguments are equal. IF(expr1,expr2,expr3) If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns expr2, else it returns expr3.  IF() returns a numeric or string value, depending on the context in which it is used: mysql> SELECT IF(1>2,2,3); -> 3 mysql> SELECT IF(1<2,'yes','no'); -> 'yes' mysql> SELECT IF(STRCMP('test','test1'),'no','yes'); -> 'no' expr1  is  evaluated  as  an  integer  value,  which  means  that  if  you  are  testing oating-point or string values, you should do so using a comparison operation: mysql> SELECT IF(0.1,1,0); -> 0 mysql> SELECT IF(0.1<>0,1,0); -> 1 In the rst case above, IF(0.1) returns 0 because 0.1 is converted to an integer value, resulting in a test of IF(0).  This may not be what you expect.  In the second case, the comparison tests the original oating-point value to see whether it is non-zero.  The result of the comparison is used as an integer. The default return type of  IF()  (which may matter when it is stored into a temporary table) is calculated in MySQL Version 3.23 as follows: Expression Return value
     

    Customer Support CentreMySQL Reference Manual

    Web Hosting Services
    UNIX WEB HOSTING
    SUPPORT & FAQ's
    TERMS OF USE
    Domain Services
    DOMAIN REGISTRATION
    MANAGE YOUR ACCOUNT
    SUPPORT & FAQ's
    TERMS OF USE
    SITE MAP
    Home
    Hosting Plans | Domain Registration | About Us | Contact Us | Site Map
    Terms of Use | Privacy Policy | Guarantees
    Merchant Accounts

    SpiritHost - web hosting for spiritual and education sites
    SpiritHit.com - Religious and Spiritual Portal
  • Return to Table of Contents
  • Back to top

  • Web Hosting: Manuals & FAQ's

    1. Unix-Based Web Hosting
    2. Unix Dedicated Servers
    3. Windows Dedicated Servers
    4. CuteFTP User’s Guide
    5. CuteHTML User’s Guide
    6. WS_FTP Pro User's Guide
    7. Miva Order User's Guide
    8. Miva Merchant User's Guide