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

else if mysql

select id, 
    (SELECT 
    IF(qty_1<='23',price,1)
    ELSEIF(('23'>qty_1 && qty_2<='23'),price_2,1)
    ELSEIF(('23'>qty_2 && qty_3<='23'),price_3,1)
    ELSEIF('23'>qty_3,price_4,1)
    END IF) as total 
 from product;
Comment

mysql if else

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

else if mysql

case 
  when qty_1<='23' then price
  when '23'>qty_1 && qty_2<='23' then price_2
  when '23'>qty_2 && qty_3<='23' then price_3
  when '23'>qty_3 then price_4
  else 1
end
Comment

PREVIOUS NEXT
Code Example
Sql :: convert multiple columns to rows in sql server 
Sql :: add multiple row table pl sql 
Sql :: between from sql 
Sql :: mysql get nth highest 
Sql :: sql right join with where clause 
Sql :: flask sqlalchemy update row 
Sql :: distinct sql 
Sql :: create table in sql server 
Sql :: mysql remove auto increment 
Sql :: SQL Modify Column in a Table -PostgreSQL 
Sql :: division by zero postgres 
Sql :: how to change column name in mysql 
Sql :: mssql datetime to date 
Sql :: select columns postgres 
Sql :: sql server drop column 
Sql :: sql server remove primary key without dropping table 
Sql :: how to display value of variable in mysql 
Sql :: how to view created temporary tables in mysql 
Sql :: postgres integer to serial 
Sql :: sql delete column 
Sql :: athena create table 
Sql :: uppercase sql 
Sql :: oracle change tablespace size 
Sql :: clear table sql 
Sql :: create empty table from existing table 
Sql :: delete from IN subquery 
Sql :: sql practice 
Sql :: SQL SELECT DISTINCT Statement 
Sql :: using SQL in rails migration 
Sql :: add week ending date sql server 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =