mysql case

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

showing results for - "mysql case"
Pia
07 May 2017
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;
Paola
08 Sep 2019
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+-------------------------------------------------------------+
Vanessa
14 Nov 2019
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
Juan Manuel
17 Jul 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;
Paulina
29 Jan 2020
1SELECT CASE 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;
Maelly
02 Jul 2019
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
sql nested ifmultiple when then in case sqlmultiple conditions in subquery in mysqloracle case when multiple conditionssql if statement in where clause multiple valuescase then els in mysqlcase in where clause mysqlcase and on where mysqlwhen multiple conditions sqlselect case when in mysqlmysql case when elsemysql case when field and fielshow case works in mysqsql where statement multiple conditionshow to write two conditions inside where in mysqlsql case when multiple andmysql case two conditionsmultiple where clause in sqlmysql case examplemultiple condition in where sqlcase statement in sql with multiple cases how use multiple condition in if in sqlmysql write select in case statementmysql when casesql select nested and casemysql case on wheremysql when case 3d valuecase staemnt in mysqlselect mysql whenswitch case syntax in sql servermysql having multiple conditions with if statementmysql case statement multiple conditionsmysql case when multiple conditionssql where multiple conditionsmultiple case when sql in where conditionsql multiple if conditionscase when with where mysqlmysql case when with andcase when end as mysqlmysql case when in case whenwhere statement with multiple conditions sqlmysql having multiple conditionsselect case when mysqlswith case in select sql serverslect using case mysqlmysql case with variablecase when mysql with ifmysql multiple if conditions with and conditioncase when en sql mysqlselect with case in mysqlcase with column values in mysqloracle case statement with multiple columnscheck 2 if conditions in mysql in select statementmysql no support case cinditionor in case in mysqlwhere clause multiple valuemariadb switch databasemysql select query with multiple conditionswhere condition with multiple values in sqlswitch mysql querymultiple if statement mysqlmysql if or caseselect case when string mysqlsql case statement in where clause multiple valuesmysql case statement with selectmysql case query for where conditionsql multiple case statementcase statement in sql with multiple conditionsmysql case in selectmysql query case whenmysql case when in selectwhere sql multiple conditionsswitch case mysql 5ccase when multiple conditions sqlcase use in mysqlswitch signs int sqlcase in result mysqlmysql case when or conditioncorrect case mysqlunion case mysqlmysql create case stament from selectmysql case phpsql multiple and conditionsswitch case my sqlcase mysql multiple conditionsmysql when thenhow can use switch in mysqlswitch uer mysqlmysql casewhenhow to write two conditions in case statement in sqlcase when mysqlnested select case sqlcase condition in mysqlcase with multiple else in sqlcase in where mysql functionmysql proper caseswitch case sql server selectswitch sqlmysql case in select statementtwo case when in mysqlwhen case in mysqlselect case mysqlmultiple conditions when sqlswitch in mysqlmultiple case when mysqlsql server procedure where conditions case statement with multiple mysql query switch casesql query where in multiple conditionssql server case statementmysql query with switch casecase with query in mysqlmysql case ifcase when in mysqlhow to use case in mysqlcase select mysqlmysql function case switchcase en mysql definicionmultiple conditions in case when sqlcase syntax in mysqlcase when is 1 mysqlswitch case mysql with set variablemysql case when and orw3 schools mysql casmultiple if in mysqlcase expression in mysqlsql case multiple whencase mysql how to uset sql case when multiple conditionsmysql table casechekc qual to in swithc case in mysqlhow to use case 2b mysqlcase im mysqlmysql case when evalueates allcase statement with multiple conditions in oraclenested if statement sql servercase statement in sql servercase on column in mysqlmysql select case examplemulti condition if in sp mysqlmariadb case whenswitch casein sql mysqlcase when in mysql with multiple conditionscase statement in mysql select querywhere clause with multiple and in sqlmysql select case elsewhere in case mysqlmysql seelect whenswitch case mysql valuesmariadb case when thencase if then mysqlt sql if with multiple conditionsmultiple where conditions sqlmysql switch case insertmysql case statement in metqbasesql switch statementsql switch caseswitch case in sql servermysql case when else ifmysql case when into case whensql when multipleswitch case sql columnmysql using case in where clausecase with or condition in mysqlsql nested if statement in selectmysql query sentence casemysql if multiple conditionsselect with case mysqlmultiple case statement in sqlmysql case when with or conditioncase when query in mysqlmysql where multiple conditionsmysql case for edge browsercase then with and or in mysqlcase in mysq 3bcase site 3amysql comsql multiple and in where clause in one querymysql switch statementuse and in case mysqluse and in case statment in mysqlcase statement in mysql case when with multiple conditions mysqlmysql sql caseselect where clause multiple valuesysql casetype case in mysqlcase column mysqlhow to multiple conditions in sqlselect column with case statement in sqlmultiple if mysqland case and mysql whenwhere clause in sql with multiple valuesmysql set casecase statement in where clause oracle with multiple conditionsmysql mutiple case whensql case multiple asmultiple values in where condition sqlcase mysql querymultiple mysql conditionsql select from where multiple conditionsthen and mysqlmultiple or condition in mysqlmultiple case sqlusing multiple where clause in sqlcase whent then in mysqlmysql case when ormysql case lesesql multiple case statementscase to execute commands sqlwhere clause sql with multiple valuesmysql swtich casesql where clause multiple valuesmysql select with casecase then mysqlswitch mariadbcase my sqlmariadb case switchsql server switch casecase statement in procedure mysqlswitch case in sqlsql server switchsql multiple where conditionsmysql 2bcasemultiple conditions on where clause sqlwhere multiple conditions sqlmysql case mysql where clause multiple conditionshow to use case when mysqlmysql if and casemysql multiple where conditionscase in mysql with andmultiple condition statements in sqlsql multiple casewhen case mysqlcase when in select mysqlcase when mariadbmysql case with andcase when select columnmysql select case not select columnmy sql syntax of casewhere clause with multiple conditionscase sql servermysql case else uppermysql select casemultiple where condition sqlselect case statement in mysqlmysql case andselect swtich case mysqlmysql case statements worksheetmysql case inside casecase statement in mysql examplecase whe is 1 mysqlt sql case when nestedoracle sql query case with or more conditionshow to use case with 2 condition in sql queryis clause in multiple condition sqlmysql case ehrn endmysql where casecheck 2 conditions in mysqlmysql case statement inside functionmysql function case statement examplesql server nested casehow use case in mysqlsql case columncase statement in where clause in mysqlselect case php mysqlcase in where mysqlcase if in mysqlmysql case when queryas and then in mysqlsql case when nestedcase en mysqlselect case when mysqlsql multiple case whenmysql case frommysql case selectswitch to sql servermariadb switch casewhat is the case statement syntax in mariadbmysql switch case in selectcase whern in mysqlmysql case insensivite likemysql case when order byhow to check two conditions in if statement in mysqlmultiple where condition in mysqlcase in mysql after wheret sql nested case in selecthow to use multiple if condition in sqlcase statement mysqlmysql case when in where conditionmariadb case when example case when in mysql querycase statement sql multiple conditionssql switchswitch case in select mysqlusing case statemnt in mysqlcase when sql servermysql case structuremysql select whenmysql case when betweensql case multiple thencase statement multiple conditions and sqlselect statement inside a case statement mysqlmysql case keywordmysql query select case whenswitch statement mysqlcase statement with multiple conditions in where clause sql servermysql when case multiple conditions ormysql 2b case when 2b defaultand case and mysqlsql case statement mysqlmysql multiple conditions in where clausewhere clause with multiple and conditionsmultiple conditions where sqlcase in where clause in mysqlcase when or when mysqlmysql case elsewhere clause in sql multiple conditionscase sql serversql query with multiple casemultiple if statements in mysql triggerhow to use multiple case when in mysqlmysql case with 3c 3e mysql case when selectmysql select if else two conditioncase statement in mysqlsql case when 2 conditionsselect column on case in sqlswitch syntax mysqlwhen in mysqloracle case statement multiple expressionssql case when multiple valueswhat is select case in mysqltsql case statement with multiple conditionone case 2 conditions sqlcheck multiple if conditions in mysqlsql server nested case when examplemysql case with multiple conditionsmysql switch case defaultswitch case sql server examplecheck 2 conditions in case sqlmysql case when else casemysql case ashow to use case in mysql select querywhen condition in mysqlselecting where condition with multiple values sqlmysql cesenested case statement in mysqlcase mysql selectsql switch column positioncase structure mysqlin sql where condition have multiple rowsmariadb when casecase when nested if statement in sqlsql statement where multiple conditionsproper case mysqlswitch case mysqlmysql where case conditionmysql multiple rows conditionmysql select in casemultiple conditions in if statement mysqlcase statement in mysql where clauseis mysql completely case inswitch case sql servercase statement multiple conditions sqlhow to use case in where clause in mysqlnested if condition in sqlsql select multiple where conditionscheck multiple conditions in mysqlselect statement in a case statement mysqlmysql multiple case whenapply manipulation on case column sqlmysql nested caseswitch case in sql select querycase in mysqlmysql case operatorupdate query with multiple case statement in sql with where conditionmysql case statementcase no myusqlhwo to igonre case in mysqlwhere clause with multiple valuesswitch case in mysql select querysql multiple then in casemysql from where case sql query multiple where conditionshow to change column value using case in sqlwhere with multiple conditions sqlcheck 2 if conditions in mysqlsql where clause with multiple valuescase 2c when 2c then mysqlcase statement for mysql querymysql multi condition andmultiple conditions in where clause sqlmultiple case in sql querymysql case datecase mysq c3 a7mysql case when andcase in mysql select querymysql case in case exampleswitch in sql servermysql case when syntaxsql where or multiple conditionscase mariadbcase then in mysqlmysql condition with multiple conditionsis in multiple condition sqladd multiple condition on sql casewhere with multiple conditions in sqlmysql trigger if multiple conditionsmy sql casesql query switch case mysql case namequery in case statement mysqlmysql case if eseifmysql select case whenmysql case when new valueswtich in mysqlmysql case insensitvemysql select switchmysql case syntaxsql update case multiple conditionscase inside case in mysqlthen end in mysqlcase for where mysqlmysql multiple conditions in where clause for same columnbetween with when case select mysqlnested case in sqlmultiple value in case statement oraclesql case when example multiplemysql case functionmultiple where conditions in sqlhow to use use case in mysqlcase if when mysqlwrite case in mysqlmysql having two conditionsselect where condition in sql multiple conditionsget from to in mysql query case thencase when syntax mysqlany case in mysqlmysql case querywhen case in mysql queryhow to have multiple when condition in sqlcase when with and mysqlmultiple if condition in sql select querymariadb case expressionssql where condition for multiple valueswhen case with or mysqlswithc case mysqlsql case multiple statements in thenmysql case statement with andmy sql case whenmysql case statement multiple conditions to checkmysql 2 case statementsnested case sqlmysql case with orsql in multiple conditionsswitch case sqlmysql case thencase sample mysqlcase if mysqlif case in mysqlswitch mysqlhow to write multiple case statements in sqlswitch statement in mysql proceduremysql case from tablemysql case orsql where multiple values clausemysql case select statementcase when mysqmysql if condition multiplecase when multiple or conditionsmultiple case in query mysqlmysql switch case in functionmysql switchselect case mysql when not in use case starment in mysqlcase in where condition in mysqlcase statement with two conditions sqlmysql add case statements togetherselect case where mysqlcase when in muysaqlsql or multiple conditionswhere multiple condition sqlmysql case when then endwhere case in mysqlsql server case 2 conditionsuse case statement in mysqlmysql select case if then as columnmysql select satament within case statementcase as mysqlthen in mysqlmultiple or in where clause sqlpython if statement multiple values in clausenested if else in sqlor in case statement mysqlmysql case statement insertmysql multiple case statementswhere clause in sql with multiple conditionsmysql switch case textmysql select case statementmultiple and in where clause sqlswitch case with select in sql servermysql swtich case syntaccase in mysql querycase when function in mysqlcase wehn mysqlmysql where 2 conditionsmysql select case when multiple conditionswhen case sql mysqlcase in select sql serversql case when multiple conditionscase when multiple conditionsselect inside a case statement mysqloracle sql query case with more conditionsswitch sql serverswitch or use mysqlcase en mysql clausesql nested case statementswitch case example in mysqlsql case nestedcan we write case statement in where clause in mysqlmysql case whencheck 2 conditions in case mysqlcase when oracle multiple conditionscase syntax for mysqlcase myswlwhen case or mysqlhow to write case in mysqlsql server case when multiplems sql switch statementcase when in where clause mariadbswitch case mssqluse switch case statement in mysqlmysql when case multiple conditionscase query in mysqlcase in sql serversql switch case examplemultiple condition in mysql querycase statement with multiple conditions in mysqlmysql select with multiple where conditionsoracle case statement multiple columnshow to use multiple if condition in sql querycase value in case statement sql what is usedsql multiple conditionswhere case when mysqlsql nested if statementmysql use case whenmysql server case whencase when is in mysqloracle sql case with multiple conditionssql query with multiple where conditionscase statement mysql syntaxcase statement with multiple conditions in sql serverhow to use two conditions in case statement in sqlmultiple condition in sql where clausemultiple case when sqlcase statement in oracle with multiple conditions examplesmysql if use several conditions sql nested case whencase when 2 conditions sqlmysql thensql multiple conditionsacase statement in where clause mysqlcase with multiple conditions in sqlmysql case in where clausemssql case when multiple conditionsmultiple case in sql serveroracle sql case statement with multiple conditionsmariadb case 3d 3d mysql if multiple conditions in selectcase column mysql end assql where clause multiple conditionshow to use case statement in mysqlcase in mysql 3bmultiple conditions in where sqlhow to use multiple where condition in sqltsql case when multiple conditionsmysql use case when without select sql statement with several conditionsmysql can you start with a case statementsql switch case statementmysql case without selectphpmyadmin case returnmysql case then in select querymysql case on selectquery case mysqlwhen mysqlcase when nested sqlmysql case stams sql switch statmentwhere case mysqlmssql case multiple conditionsmysql case when casemysql set with casecase and end mysqlmultiple condition in case statement in sqlmysql 2b switchcase in mysqnested case statement in sqlsql where with multiple conditionsoracle sql case when multiple conditionsexecute command in case syjntax of mysqlmysql case stop breakmysql query in caseshow to switchthe values in a column in sqlcase statement in oracle with multiple conditionsmysql case tablewhere condition multiple valuesmysql case when havingmysql case calculoscase functionmysql case in wherepl 2fsql case when multiple valuesswitch case in mysqlmysql show the case off the where clauseset into case condition mysqlmultiple if condition in mysqltable switch mysqlcase when sql multiple conditionsmultiple conditions in on sqlsql change column value casesql select where multiple conditionsmysql case as in selectmultiple where conditions in mysqlcase when sql server multiple conditionsmysql query case iftwo case when conditions in sqlt sql multiple case whenmysql casemysql can i case when a table 3fmysql select case if thenmysql whencase statement mysql operatorsmysql multiple if conditionscase in mariadbhow to do multiple when statements sqlmysql switch casemysql set case whencase syntax mysqlsql multiple case whenuse case with where mysqlusing case in mysqlcase statement sql server multiple conditionssql case when multiple thencases in mysqlcase when then in mysqlcase statements mysqlor in case mysqlmysql case when more than 1 conditionsql multiple conditions where clausemysql switch case in procedurecase function inmysql workbench case when mysqlhow to put two conditions in case statement in oracle sqlmysql case case defaultcase when else if mysqlmariadb case statementmysql where case statement examplemysql case d 25mysql if 2 conditionscase mysqlselect query inside case statement in mysqlsql when multiple conditionsoracle sql query case with in more conditionsnested case statement in oraclecase no mysqlmysql case when in where clausecase statement sql serversql multiple where conditions with having statementcase with where clause in mysqlsql function using switch casehow to write multiple where condition in sqlswitc casa mysqlcase when mysql examplecase in mysql selectmariadb caseswicth case mysqlcase statement syntax mysqlcase when then mysqlsql nested case statementsmysql when then elsemysql case setncenmariadb switch case exampleselect mysql where multiple conditionsmysql select case replacemysql case whenelsemultiple where condition in querycase when if mysqlswitch case in myswlsql if else where multiple valuemysql multiple and conditionscase when then in mysqkmultiple case statements in sqlmysql query switch case wheresql if statement multiple conditionscheck multiple if using and conditions in mysqlmysql where case whenmysql case with conditions betweenmultiple when in case sqlmultiple case statements sqlmysql case statement keywordscase when in select statement mysqlmysql function switch casewhere clause multiple valuessql query where multiple conditionscase when in myslqcase when else when mysqlalter table switchmysql case switchcase when trong mysqlsql if multiple conditionsmysql case example tutorialmultiple where condition in sqlmysql case in create tablecase when 2 conditions mysqlcase wehn sql servermysql case 28 29sql case when multiplecase statement default mysqlsql multiple logical and in if conditionscase in select statement in mysqlselect case statement mysqlcase in mysqlmysql case when multipleswitch in mysql queryadd case in mysqlhow to use case when in nested conditions in sqlmysql update case multiple conditionsthen mysqlcase when with multiple conditionssql case multiple conditionsmysql select in case statementmultiples conitions case sqlcase statements in mysqlmysql case when thencase default in mysqlcase when select mysqlsql statement with multiple where conditionshow do you perform operations in case statement in mysqland in case mysqlnest case whens mysqlmysql case statement in select clausecase in my sqlmysql query case when only using onemysql case statement equal tomultiple conditions case count sqlselect case in mysqlswitch statements mysql selectswitch columns in sqlmysql case when two conditionsmysql function case when sql switch to tablemysql where clause multiple or conditionscase when select mysqcase when condition in mysqlmysql multiple caseuse case in mysql where clausesql case with multiple conditionsis case is available in mysqlcase when mysql syntaxmariadb case when null thenhow to switch from mariadb to mysqlsql case statement with multiple conditionswhen case mysql examplecase where mysqlmysql case