mysql switch case

Solutions on MaxInterview for mysql switch case by the best coders in the world

showing results for - "mysql switch case"
Amanda
28 Jan 2020
1SELECT CASE lower(col1)
2	WHEN 'agree' THEN 'Ok'
3	WHEN 'disagree' THEN 'Ko'
4    ELSE
5        CASE 
6            WHEN col2 = 1 THEN 'Ko'
7            ELSE 'Maybe'
8        END
9END AS my_result
10FROM table_name;
Elina
25 May 2017
1mysql> SELECT CASE  WHEN 2>3 THEN 'this is true' ELSE 'this is false' END; 
2+-------------------------------------------------------------+
3| CASE  WHEN 2>3 THEN 'this is true' ELSE 'this is false' END |
4+-------------------------------------------------------------+
5| this is false                                               | 
6+-------------------------------------------------------------+
Audrey
04 May 2017
1-- LABEL MOVIE LENGTH 
2select title, length,
3CASE 
4	 when length < 50 then 'very short film'
5     when length < 90 then 'short film'
6     when length < 120 then 'medium length film'
7     when length > 120 then 'long film'
8     else 'unknown length'
9END -- AS film_length
10from film;
11
12-- SAME AS ABOVE BUT ON A CUSTOM NAMED COLUMN
13select title, length,
14CASE 
15	 when length < 50 then 'very short film'
16     when length < 90 then 'short film'
17     when length < 120 then 'medium length film'
18     when length > 120 then 'long film'
19     else 'unknown length'
20END  AS film_length
21from film;
22
23-- RESULT
24+-----------------------------+--------+--------------------+
25| title                       | length | film_length        |
26+-----------------------------+--------+--------------------+
27| ACADEMY DINOSAUR            |     86 | short film         |
28| ACE GOLDFINGER              |     48 | very short film    |
29| ADAPTATION HOLES            |     50 | short film         |
30| AFFAIR PREJUDICE            |    117 | medium length film |
31| AFRICAN EGG                 |    130 | long film          |
32| AGENT TRUMAN                |    169 | long film          |
33| AIRPLANE SIERRA             |     62 | short film         |
34| AIRPORT POLLOCK             |     54 | short film         |
35| ALABAMA DEVIL               |    114 | medium length film |
36| ALADDIN CALENDAR            |     63 | short film         |
37| ALAMO VIDEOTAPE             |    126 | long film          |
38| ALASKA PHANTOM              |    136 | long film          |
39| ALI FOREVER                 |    150 | long film          |
40| ALICE FANTASIA              |     94 | medium length film |
41| ALIEN CENTER                |     46 | very short film    |
42
Dawn
19 Mar 2020
1SELECT
2    CASE 
3        WHEN
4            column IS NULL OR another_column = 1
5        THEN
6            'yes' 
7        ELSE
8            'no' 
9    END AS 'MyData'
10FROM
11    table_name;
Joshua
24 Jan 2020
1SELECT 
2t2.company_name,
3t2.expose_new,
4t2.expose_used,
5t1.title,
6t1.status,
7 CASE status
8   when 'New' and t2.expose_new = 1 then 1
9   when 'New' and t2.expose_new = 2 then 2
10   when 'New' and t2.expose_new = 3 then 3
11   when 'Used' and t2.expose_used = 1 then 1
12   when 'Used' and t2.expose_used = 2 then 2
13   when 'Used' and t2.expose_used = 3 then 3
14END as expose
15FROM `products` t1
16join manufacturers t2 on t2.id = t1.seller
17where t1.seller = 4238
queries leading to this page
case if mysqlmysql select with case case when in mysql querywhere case in mysqlmysql case on selectcase statement default mysqlmysql case statement with selectswitch syntax mysqlwhere case when mysqlswitc casa mysqlmysql if or caseuse case statement in mysqlcase myswlsql query switch case mysql add case statements togethercase 2c when 2c then mysqlsql switch column positioncase when if mysqlysql casemysql case query for where conditioncase statement in mysqlis case is available in mysqlmysql server case whenthen end in mysqlmysql case when order bymysql select case replacecase in mysqlcase mysql how to usemysql query switch case wherewhere in case mysqlhow to use case in mysqlmysql casewhenmy sql case whenselect case mysqlmysql 2bcasecase structure mysqlcase as mysqlcase en mysql clausecase expression in mysqlcase statements in mysqlcase syntax mysqlcase if then mysqlmysql no support case cinditionmariadb case when null thencase statement in mysql case in where mysql functionwhen case in mysql querywhere case mysqlmysql query in casescase in mysql 3bmariadb switch casemysql case statement with andmysql if and casemysql select case examplecase mysq c3 a7execute command in case syjntax of mysqlmysql switch casecase whe is 1 mysqlmysql case with 3c 3e mysql use case whenmysql switch case in selectmysql where casemysql query with switch casemysql whenmysql switch case in functionmysql case when in where clausemysql function case switchmysql case andmysql case selectcase statement in mysql examplewhen condition in mysqlcase default in mysqlmariadb switch case examplewhen case with or mysqlmariadb when casemysql case statement in metqbasecase in where clause in mysqlhow do you perform operations in case statement in mysqlcase with query in mysqlcase and end mysqlselect with case mysqlcase mysqlselect case mysql when not in mysql query switch casehow use case in mysqlcase whent then in mysqlswitch or use mysqlmariadb case 3d 3d switch mysqlmysql case in selectmysql proper casecase my sqlmysql query case whenswitch statement mysqlwhen case sql mysqlcase statement in procedure mysqlcase value in case statement sql what is usedselect mysql whenor in case in mysqlmysql case with orcase in where mysqlcase statement in where clause mysqlselect case when mysqlcase statement mysql operatorscase in mysqlcase functionuse switch case statement in mysqlmysql case ehrn endand in case mysqlmysql when case 3d valuecase then in mysqlcase when query in mysqlmysql case fromcase when in where clause mariadbis mysql completely case inmysql case in case exampleswitch case in sqlcase when in myslqhow to use case 2b mysqlcase statement in mysql where clausethen mysqlmysql case when thencase when select columnthen and mysqlswitch case mysql with set variablecase column mysqlmysql select in casecase when select mysqlswitch case in mysqlmysql table casemysql case when else ifmysql case inside casemysql case as in selectmariadb casemysql case structuremysql set with casemysql case select statementmysql case tablewrite case in mysqltype case in mysqlcase statement in mysql select queryswitch case in select mysqlmysql case when orcase when in muysaqlmysql case for edge browserswitch sqlmysql from where case mysql case in where clausemysql case in wherecase en mysqlcase mysql selectmysql case whencase if when mysqlswitch case sql columnmysql case statementmysql case when querycase and on where mysqland case and mysqlcase statement mysqlmysql case oradd case in mysqluse case with where mysqlcase select mysqlcase condition in mysqlmysql when thencase inside case in mysqluse case starment in mysqlswitch case example in mysqlmysql set case whencase when mysqmysql can i case when a table 3fand case and mysql whenas and then in mysqlmysql switchmysql case statement equal tocase on column in mysqlcase when else when mysqlcase wehn mysqlmysql case statements worksheetwhen case in mysqlmysql where case whencase when mysql syntaxcase if in mysqlswitch in mysqlcase in my sqlmysql show the case off the where clauseswtich in mysqlmysql select casemysql select case if then as columnmysql case when with or conditionmariadb case switchswitch mysql querycase when end as mysqlmysql case if eseifcase syntax for mysqlmysql where case conditionset into case condition mysqlphpmyadmin case returnmysql case when else casemysql casecase in mysql selectcases in mysqlselect case php mysqlmysql case when evalueates allcase then mysqlmysql case ifcase when with where mysqlswitch case my sqlmysql case switchapply manipulation on case column sqlselect case when mysqlmysql case from tableselect case when string mysqlwhat is select case in mysqlmysql case then in select queryhow to use case statement in mysqlcase in mysql after wheremysql case stamysql switch case insertmysql case syntaxmysql case when in selectcase sample mysqlwhen mysqlcase in mysql querycase function inswitch statements mysql selectswicth case mysqlselect case where mysqlmysql case 28 29use case in mysql where clausecase in result mysqlmysql case d 25mysql case datecase when then in mysqkwhen case or mysqlmysql switch statementhow to change column value using case in sqlmysql case thenmysql swtich case syntacsql switch statementselect column on case in sqlwhat is the case statement syntax in mariadbmariadb switch databaseswitch signs int sqluse and in case statment in mysqlmysql case operatormysql select whenmysql sql casemysql using case in where clausemysql when caseslect using case mysqlcase column mysql end ascase for where mysqlcase when function in mysqlsql change column value casecase with where clause in mysqltable switch mysqlselect case in mysqlswitch casein sql mysqlmysql case example tutorialmysql case setncencorrect case mysqlhow to switch from mariadb to mysqlswitch uer mysqlcase in mariadbhow can use switch in mysqlcase in mysqmysql switch case defaultmysql case statement inside functionmysql case when betweenmysql select case elsemysql case keywordquery in case statement mysqlmysql case when syntaxmysql can you start with a case statementhwo to igonre case in mysqlswitch case mysql 5cswitch in mysql querymysql select in case statementmysql case calculossql case statement mysqlmysql case statement in select clauseswitch case mysqlmy sql syntax of casehow to use case when mysqlmysql case mysql case without selectmysql select case statementcase when mysql with ifor in case mysqlcase no myusqlselect swtich case mysqlswitch mariadbselect case statement in mysqlcase in where condition in mysqlmysql case statement insertmysql 2b case when 2b defaultmysql query select case whenuse and in case mysqlcase when else if mysqlmysql function case statement examplecase when en sql mysqlmariadb case statementselect column with case statement in sqlusing case in mysqlcase when is 1 mysqlmysql case when and orcase use in mysqlcase with column values in mysqlcase en mysql definicionmysql case phphow to use case in mysql select querysql switchhow to write case in mysqlmariadb case when exampleswithc case mysqlcase syntax in mysqlmysql case when or conditionmysql query sentence casemysql workbench casecase in mysql with andmysql thenmysql case when into case whenmysql case when in case whenhow case works in mysqhow to use use case in mysqlmysql case insensitvemysql function case when case statement in where clause in mysqlmysql case lesequery case mysqlmariadb case whenor in case statement mysqlget from to in mysql query case thenmysql case with conditions betweenselect case when in mysqlcase mysql querymysql case when havingmy sql casemysql when then elseswitch case mysql valuesmysql cesehow to use case in where clause in mysqlcase in mysql select queryusing case statemnt in mysqlswitch columns in sqlmysql case asselect statement in a case statement mysqlunion case mysqlmysql case when then endsql switch casecase when condition in mysqlcase when mariadbmysql case insensivite likecase when in mysqlcase site 3amysql comthen in mysqlmysql case when with andcase when trong mysqlswitch case in mysql select queryany case in mysqlmysql case statement keywordsswitch case in myswlmysql 2b switchcase in where clause mysqlmysql case in select statementswitch statement in mysql procedurecase when select mysqmariadb case when thencase when in select statement mysqlwhen case mysqlcase with or condition in mysqlcase where mysqlmariadb case expressionsselect case statement mysqlselect with case in mysqlmysql case with variablemysql case in create tablecase when then mysqlmysql case when casecase when or when mysqlmysql case when andmysql case when new valuemysql case when in where conditioncase when in select mysqlmysql case case defaultmysql set casemysql function switch casecase then els in mysqlmysql case stop breakmysql swtich casemysql query case ifmysql switch case in procedurecase mariadbmysql case when selectmysql case elsecase query in mysqlmysql case else upperw3 schools mysql casmysql select case whenmysql case functionproper case mysqlcase statement mysql syntaxcase when is in mysqlmysql switch case textchekc qual to in swithc case in mysqlcase when then in mysqlmysql case querysql switch to table when mysqlcase staemnt in mysqlcase to execute commands sqlwhen in mysqlcase when with and mysqlmysql select switchmysql where case statement exampleif case in mysqlcase when mysqlmysql case namecase statement syntax mysqlcase when syntax mysqlcase im mysqlcase statement for mysql querymysql case when field and fielsbetween with when case select mysqlmysql case examplemysql seelect whencase then with and or in mysqlcase in mysq 3bcase in select statement in mysqlsql switch case statementmysql case when elsecase no mysqlmysql switch case