Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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

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 statement in where clause

SELECT  `id` ,  `naam` 
FROM  `klanten` 
WHERE IF(`email` != '', `email`, `email2`) LIKE  '%@domain.nl%'
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 :: mariadb case switch 
Sql :: not between mysql 
Sql :: mysql server not running 
Sql :: mysql 5.6 hierarchical recursive query 
Sql :: oracle db timestamp auto add 
Sql :: soql update query 
Sql :: get stored procedure text sql server 
Sql :: sql server remove 0 from left 
Sql :: how to recreate postgres database in docker 
Sql :: copy from one table to another postgres using matching column 
Sql :: SQL Query to delete all the tables in a database 
Sql :: dump multiple tables mysql 
Sql :: multiple row primary key 
Sql :: mysql date_format 
Sql :: enum in sql server 
Sql :: pl sql create function 
Sql :: sql update multiple tables 
Sql :: SQL Server Splitting a string column into multiple rows, while repeating ID column 
Sql :: last 2 mins sql server 
Sql :: grant select mysql 
Sql :: how to delete python anywhere mysql database 
Sql :: Postgres format number to 2 decimal places 
Sql :: How to take sum of column with same id and different table in SQL? 
Sql :: SQL SUM() Function 
Sql :: oracle merge insert if not exists 
Sql :: delete from table where length sql 
Sql :: postgres sql alter table delete row 
Sql :: merge command in sql 
Sql :: select only columns that are not empty oracle sql 
Sql :: what is postgresql 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =