TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL IF Function

Overview

In this tutorial, we will learn about MySQL IF Function with some examples. The IF statement tests the expression in the first argument and returns its second argument if the expression is true or otherwise, returns the third argument.

Syntax

The general syntax of the IF function is as follows:

IF(exp1,exp2,exp3)

Example

mysql> SELECT IF(4=4,’True’,’False’);
+————————+
| IF(4=4,’True’,’False’) |
+————————+
| True |
+————————+
1 row in set (0.00 sec)

Here 4=4 is true so the second argument is returned by the function.

mysql> SELECT IF(5 > 9,’True’,’False’);
+————————–+
| IF(5 > 9,’True’,’False’) |
+————————–+
| False |
+————————–+
1 row in set (0.00 sec)

 

Since 5 is not greater than 9 the third argument False is returned. There is also IF statement that is used in stored procedures. The IF statement is a conditional statement.

MySQL IF Function

 

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

DataGrip Desktop Shortcut

MySQL /

Launch DataGrip on Windows

DataGrip Download

MySQL /

Install DataGrip IDE on Windows 11

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

‹ MySQL LIKE Operator› MySQL Connectors

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com