Saturday, February 28, 2009
MySQL IF, MySQL IFNULL - Control Flow Functions
Keywords: MySQL, MySQL Control Flow Functions, MySQL IF, MySQL IFNULL, MySQL IF & IFNULL, MySQL Select IF Statements, MySQL Select
MySQL IF - Control Flow Functions
In MySQL, there is a "IF" function allows us deciding the output string in the select statement:-
Syntax:-
mysql> IF( expr1, expr2, expr3)
If expr1 is not NULL, IFNULL() returns expr1; otherwise it returns expr2.
Example:-
mysql> select if( user_sex = 'M', 'Male', 'Female') as sex from users;
The above select statement will return 'Male' or 'Female' depends on the column value 'M'or 'F'.
There are some case we may not want "NULL" as output, in that case, use mysql IFNULL( )
Syntax:-
mysql> IFNULL( expr/column, 'Replacing Output String' );
IFNULL() returns a numeric or string value, depending on the context in which it is used.
Example:-
mysql> select IFNULL( addresscolumn, 'No Address Provided' ) from users;
Keywords: MySQL, MySQL Control Flow Functions, MySQL IF, MySQL IFNULL, MySQL IF & IFNULL, MySQL Select IF Statements, MySQL Select
Featured Blog Topics:
- MySQLDUMP: Taking Backup of Multiple Databases - http://kathyravan.blogspot.com/2009/02/mysqldump-taking-backup-of-multiple.html
- MySQL LEFT JOIN - http://kathyravan.blogspot.com/2009/01/mysql-left-join.html
- MySQL SQL_CACHE - http://kathyravan.blogspot.com/2008/12/mysql-sqlcache.html
- MySQL Query Caching - http://kathyravan.blogspot.com/2008/12/mysql-query-cache.html
- MySQL Show - http://kathyravan.blogspot.com/2008/12/mysql-show-statements.html
- CSV - MySQL Storage Engine - http://kathyravan.blogspot.com/2008/12/csv-mysql-storage-engine.html
- Blackhole - MySQL Storage Engine - http://kathyravan.blogspot.com/2008/12/blackhole-mysql-storage-engine.html
- Memory - MySQL Storage Engine (Formerly Heap Storage Engine) - http://kathyravan.blogspot.com/2008/12/memory-mysql-storage-engine-formerly.html
- Xml in MySQL - http://kathyravan.blogspot.com/2008/03/xml-in-mysql.html
- Forgot mySQL root Password? - http://kathyravan.blogspot.com/2008/02/forgot-mysql-root-password.html
- Samba - Installation & Configuration - http://kathyravan.blogspot.com/2008/02/samba-installation-configuration.html
- Enabling HTTP Authentication in Apache - http://kathyravan.blogspot.com/2008/08/enabling-http-authentication-in-apache.html
- PHP Function: isFTPFileExists (Searching a FILE in FTP) - http://kathyravan.blogspot.com/2008/12/php-function-isftpfileexists-searching.html
- Shell Scripting & Linux - http://kathyravan.blogspot.com/search/label/Shell%20Scripts
- SBI's New Home Loan Scheme - http://paisamechanic.blogspot.com/2009/02/sbis-special-home-loan-scheme.html
- ATM Locations in Chennai - http://paisamechanic.blogspot.com/search/label/ATM%20Locations%20-%20Chennai
- Deutsche Bank ATM Locations - http://paisamechanic.blogspot.com/search/label/Deutsche%20Bank%20ATM%20Locations
- SBI ATM Locations - http://paisamechanic.blogspot.com/search/label/SBI%20ATM%20Locations
- iMobile - ICICI Bank's New age of Mobile Banking
- HSBC Cheque Drop Box Locations -http://paisamechanic.blogspot.com/search/label/HSBC%20Cheque%20Drop%20Box%20Locations
- CITIBANK Cheque Drop Box Locations -http://paisamechanic.blogspot.com/search/label/Citibank%20Cheque%20Drop%20Box%20Locations
- Standard Chartered Bank Cheque Drop Box Locations - http://paisamechanic.blogspot.com/search/label/Citibank%20Cheque%20Drop%20Box%20Locations
- IFSC Code Definition - http://paisamechanic.blogspot.com/2008/12/ifsc-code-definition.html
- IFSC Codes of All Banks - http://paisamechanic.blogspot.com/2008/12/ifsc-codes-of-indian-banks.html
- IFSC Codes of Deutsche Bank - http://paisamechanic.blogspot.com/2009/01/ifsc-codes-of-deutsche-bank.html
- IFSC Codes of Syndicate Bank - http://paisamechanic.blogspot.com/2009/01/ifsc-codes-of-syndicate-bank.html
- IFSC Codes of Andhra Bank - http://paisamechanic.blogspot.com/search/label/IFSC%20Codes%20-%20Andhra%20Banks
- OneView HDFC Bank - All in One Internet Banking -http://paisamechanic.blogspot.com/2008/12/oneview-hdfc-bank-all-in-one-internet.html
- EMI Calculator - http://paisamechanic.blogspot.com/2008/12/emi-calculator.html
- Standard Chartered Bank Cheque Drop Box Locations Chennai -http://paisamechanic.blogspot.com/2008/12/standard-chartered-bank-cheque-drop-box.html
- Standard Chartered Bank Cheque Drop Box Locations Bangalore -http://paisamechanic.blogspot.com/2008/12/standard-chartered-bank-cheque-drop-box.html
- Reliance Guarantee Return Plan- http://paisamechanic.blogspot.com/2008/12/reliance-guarantee-return-plan.html
- SBI NEFT Fund Transfer - http://paisamechanic.blogspot.com/2008/12/sbi-neft-fund-transfer.html
- IFSC Codes of Indian Banks - http://paisamechanic.blogspot.com/2008/12/ifsc-codes-of-indian-banks.html
- Mobile Showroom Locations - http://paisamechanic.blogspot.com
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment