Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql if else

SELECT OrderID, Quantity, 
CASE WHEN Quantity > 10 THEN "MORE" ELSE "LESS" END as x
FROM OrderDetails;

SELECT OrderID, Quantity, 
IF (Quantity > 10, "MORE", "LESS") as x
FROM OrderDetails;
Comment

mysql else if

IF condition1 THEN
    statements;
ELSEIF condition2 THEN # OPTIONAL
	statements;
ELSE # OPTIONAL
    statements;
END IF;
Comment

if in mysql

The if accept one condition, if this condition is true then the true_value will occur 
else the false_value will occur.
IF(condition, true_value, false_value)
Tips : can be to update some data
Comment

mysql if

SELECT user_display_image AS user_image,
       user_display_name AS user_name,
       invitee_phone,
       (CASE WHEN invitee_status = 1 THEN "attending"
             WHEN invitee_status = 2 THEN "unsure"
             WHEN invitee_status = 3 THEN "declined"
             WHEN invitee_status = 0 THEN "notreviwed"
       END) AS invitee_status
  FROM your_table
Comment

if mysql

SELECT IF(500<1000, "YES", "NO");
Comment

mysql if statement

-- PL/SQL
BEGIN
    IF my_val = 1 THEN [...]
    ELSE [...]
    END IF;
END;
-- In a query
SELECT CASE WHEN my_col = 1 THEN 'Ok' ELSE 'Ko' END AS my_result;
Comment

mysql if else

IF condition THEN
   statements;
ELSE
   else-statements;
END IF;
Comment

mysql if statement in where clause

SELECT  `id` ,  `naam` 
FROM  `klanten` 
WHERE IF(`email` != '', `email`, `email2`) LIKE  '%@domain.nl%'
Comment

PREVIOUS NEXT
Code Example
Sql :: oracle sql number to varchar2 
Sql :: check for directory in bash 
Sql :: sql data types 
Sql :: pl sql case 
Sql :: sql top 3 for each group 
Sql :: oracle sql average 
Sql :: how to get all dates in a month in oracle 
Sql :: How to find string in substring in sql server 
Sql :: Write an SQL query to fetch worker names with salaries = 50000 and <= 100000. 
Sql :: Add new column T-SQL 
Sql :: sqlite 3 mac 
Sql :: database get 10 user aleatory 
Sql :: Grant privileges of databse to user 
Sql :: phone number regex sql 
Sql :: sql statement to change a field value 
Sql :: how covert into int in maria db 
Sql :: json_remove mysql 
Sql :: forcefully delete a row in mysql which has references 
Sql :: sql distinct 
Sql :: what is relational database 
Sql :: split string and get first and last element in sql server 
Sql :: alter table query in mysql 
Sql :: SQL Server OPENQUERY WITH result SETS 
Sql :: Import zipped mysql dumps 
Sql :: lost connection to mysql server during query when dumping table 
Sql :: drop database mysql 
Sql :: sql update multiple tables 
Sql :: ORACLE CALL BACK TRACE 
Sql :: oracle list user locked 
Sql :: no suitable driver found for sqlite 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =