jcgj.net
当前位置:首页 >> mysql CAsE whEn用法 >>

mysql CAsE whEn用法

直接加在语句最后就行了。 UPDATE `member` SET score = (CASE WHEN score IS NOT NULL THEN score = 0 ELSE score = 1 END) where id =1; mysql数据库中CASE WHEN语句。 case when语句,用于计算条件列表并返回多个可能结果表达式之一。 CASE ...

mysql> CREATE FUNCTION HelloWorld4() -> RETURNS VARCHAR(20) -> BEGIN -> RETURN 'Hello World!'; -> END; -> // Query OK, 0 rows affected (0.00 sec) mysql> select HelloWorld4() // +---------------+ | HelloWorld4() | +-------------...

你应该这样写 select * from 表 where 1=1 and (case when a=1 then a when 表.字段='asdfasdf' then b end)='值

可以的,group by后边整个条件 就是列: CASE country WHEN'中国' THEN'亚洲' WHEN'印度' THEN'亚洲' WHEN'日本' THEN'亚洲' WHEN'美国' THEN'北美洲' WHEN'加拿大' THEN'北美洲' WHEN'墨西哥' THEN'北美洲' ELSE'其他'END

举例说明 SELECT CASE a.AFTER_QUALITY WHEN '0' THEN '过免维期' WHEN '1' THEN '未过免维期' ELSE '错误数据' END AS AFTER_QUALITY FROM t_maintain_log a 数据库表内容:

`oid` bigint(20) NOT NULL, `o_source` varchar(25) DEFAULT NULL COMMENT '来源编号', `o_actno` varchar(30) DEFAULT NULL COMMENT '活动编号', `o_actname` varchar(100) DEFAULT NULL COMMENT '参与活动名称', `o_n_channel` int(2) DEFAUL...

试试这个,没有测试: select date, sum(if(a = 1, 1, 0)) as A1, sum(if(a = 2, 1, 0)) as A2from tab where a=1group by date

select case when diff_flg=0 then jet_nm+'哈哈哈' else diff_flg END from je_test where je_id = 1

select case when vipStartDate is null then '9999999999' else vipStartDate end as vipStartDate from 表

网站首页 | 网站地图
All rights reserved Powered by www.jcgj.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com