mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
eebc67f6f8
BitKeeper/etc/logging_ok: auto-union VC++Files/sql/mysqld.dsp: Auto merged acinclude.m4: Auto merged include/my_base.h: Auto merged include/myisam.h: Auto merged include/myisammrg.h: Auto merged libmysql/libmysql.c: Auto merged myisam/mi_check.c: Auto merged myisam/mi_write.c: Auto merged myisam/myisamdef.h: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/case.result: Auto merged mysql-test/r/distinct.result: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/key_diff.result: Auto merged mysql-test/r/multi_update.result: Auto merged mysql-test/r/order_by.result: Auto merged mysql-test/r/select.result: Auto merged mysql-test/r/show_check.result: Auto merged mysql-test/t/multi_update.test: Auto merged mysql-test/t/rpl_log_pos.test: Auto merged mysys/Makefile.am: Auto merged scripts/Makefile.am: Auto merged sql/field.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_myisammrg.cc: Auto merged sql/ha_myisammrg.h: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_create.h: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/lex.h: Auto merged sql/log.cc: Auto merged sql/net_serv.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_udf.cc: Auto merged sql/sql_update.cc: Auto merged sql-bench/crash-me.sh: Auto merged sql-bench/server-cfg.sh: Auto merged sql/share/english/errmsg.txt: Auto merged sql/structs.h: Auto merged
73 lines
2.6 KiB
Text
73 lines
2.6 KiB
Text
drop table if exists t1;
|
|
select CASE "b" when "a" then 1 when "b" then 2 END;
|
|
CASE "b" when "a" then 1 when "b" then 2 END
|
|
2
|
|
select CASE "c" when "a" then 1 when "b" then 2 END;
|
|
CASE "c" when "a" then 1 when "b" then 2 END
|
|
NULL
|
|
select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END;
|
|
CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END
|
|
3
|
|
select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END;
|
|
CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END
|
|
0
|
|
select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END;
|
|
CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END
|
|
0
|
|
select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end;
|
|
CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end
|
|
a
|
|
select CASE when 1=0 then "true" else "false" END;
|
|
CASE when 1=0 then "true" else "false" END
|
|
false
|
|
select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
|
|
CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END
|
|
one
|
|
select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
|
|
CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END
|
|
two
|
|
select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0;
|
|
(CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0
|
|
2
|
|
select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0;
|
|
(CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0
|
|
2.00
|
|
select case 1/0 when "a" then "true" else "false" END;
|
|
case 1/0 when "a" then "true" else "false" END
|
|
false
|
|
select case 1/0 when "a" then "true" END;
|
|
case 1/0 when "a" then "true" END
|
|
NULL
|
|
select (case 1/0 when "a" then "true" END) | 0;
|
|
(case 1/0 when "a" then "true" END) | 0
|
|
NULL
|
|
select (case 1/0 when "a" then "true" END) + 0.0;
|
|
(case 1/0 when "a" then "true" END) + 0.0
|
|
NULL
|
|
select case when 1>0 then "TRUE" else "FALSE" END;
|
|
case when 1>0 then "TRUE" else "FALSE" END
|
|
TRUE
|
|
select case when 1<0 then "TRUE" else "FALSE" END;
|
|
case when 1<0 then "TRUE" else "FALSE" END
|
|
FALSE
|
|
create table t1 (a int);
|
|
insert into t1 values(1),(2),(3),(4);
|
|
select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase;
|
|
fcase count(*)
|
|
0 2
|
|
2 1
|
|
3 1
|
|
select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase;
|
|
fcase count(*)
|
|
nothing 2
|
|
one 1
|
|
two 1
|
|
drop table t1;
|
|
create table t1 (row int not null, col int not null, val varchar(255) not null);
|
|
insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small');
|
|
select max(case col when 1 then val else null end) as color from t1 group by row;
|
|
color
|
|
orange
|
|
yellow
|
|
green
|
|
drop table t1;
|