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

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 :: Save PL/pgSQL output from PostgreSQL to a CSV file 
Sql :: SQL Add Column in a Table 
Sql :: mysql find duplicates 
Sql :: datediff in sql 
Sql :: how to find all children of a record with only parent ID in sql 
Sql :: postgres integer to serial 
Sql :: drop function in sql 
Sql :: mysql function 
Sql :: ms sql database data size 
Sql :: make date with time sql 
Sql :: mysql create table query 
Sql :: PL SQL VARRAY of records 
Sql :: unable to convert mysql date/time value to system.datetime 
Sql :: oracle change tablespace size 
Sql :: plpgsql if statement 
Sql :: what is having clause in sql 
Sql :: create table from existing table in sql 
Sql :: add foreign key to existing table postgres 
Sql :: count the table indatabase 
Sql :: tablas bootstrap responsive sql server para datos vivos 
Sql :: How to get last inserted primary key in SQL Server 
Sql :: mysql timezone 
Sql :: mysql changer nom table 
Sql :: oracle get ddl 
Sql :: installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1 
Sql :: mysql group concat 
Sql :: mysql regexp replace 
Sql :: initcap in sql 
Sql :: delete all duplicate rows keep the latest except for one in mysql 
Sql :: oracle find foreign key dependencies 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =