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

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

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

MySQL if condition

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

PREVIOUS NEXT
Code Example
Sql :: uncheck constraints and delete from table 
Sql :: select only the month-day from date in PL-SQL 
Sql :: select case when oracle 
Sql :: android sqlite database example 
Sql :: oracle all dates between two dates 
Sql :: sql where contains part of string 
Sql :: sql count more than 1 
Sql :: select value from previous row in postgresql 
Sql :: smallint sql 
Sql :: insert query mysql workbench 
Sql :: homebrew install mysql 
Sql :: convert rows into columns in oracle 
Sql :: sql if null then string 
Sql :: oracle gather table statistics 
Sql :: case insensitive sql 
Sql :: mysql show slave status 
Sql :: insert many to many sql 
Sql :: android sqlite query join 
Sql :: mysql select case insensitive 
Sql :: joins in sql 
Sql :: mysql group by 
Sql :: java sql insert return id 
Sql :: json to dynamic columns in sql 
Sql :: between date in sql server 
Sql :: select only unique values from and to current table 
Sql :: having clause 
Sql :: SQL/update 
Sql :: azure check access to sql database 
Sql :: mysql grouping functions 
Sql :: Search In the Database using Text 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =