/    /  MySQL – Conditions

MySQL – Conditions

 

conditions

Condition is an open-source Relational Database Management System (RDBMS) that uses a standard language called SQL – Structured Query Language for manipulating, storing and retrieving records. The MYSQL database server is a quick, secure, and easy-to-use application suitable for a wide range of applications – such as web databases, data warehousing, e-commerce, logging, and many more.

There may be one or more tables in a database, each with rows and columns. A table is represented by a name, while SQL statements are used to perform any action on a database. We will discuss conditional statements in MySQL which are based on conditional expressions. Any arrangement of MySQL literals, such as variables, operators, and functions, can be defined as an expression.

Conditional Operators in MySQL

  • IF() Function – A TRUE condition leads to the result “YES”, whereas a FALSE condition leads to the result “NO”.
  • COALESCE () Function – The result of this operation is the first non-null value in the list.
  • CASE Function –  It checks all the conditions and if the first condition is met, returns a value and does not continue reading. When no conditions are met, the value will be displayed in the ELSE clause. It will, however, return NULL if there is no ELSE or conditional expression.
  • ISNULL Function – If the expression is NULL, it returns 1, otherwise it returns 0.
  • NULLIF Function – It returns NULL if two expressions are equal on comparison. If not, then the result is the first expression.
  • IFNULL Function – The expression returns a particular value if it is NULL and the expression if it is NOT NULL.
  • GREATEST – Upon combining two or more terms, it results in the largest value. The list returns NULL if any conditional expression is NULL.
  • IN – The function determines whether a value belongs to a set of values given or listed. It can be used with CHECK, WHERE, and view creation.
  • LEAST – The function returns the least value from the list of two or multiple expressions, and if there is a NULL value expression in the list, the result will be NULL.