一个复杂的mysql查询语句(case,when,then,left join )

select `a`.`id` AS `id`,`a`.`UserName` AS `UserName`,

 

(case when (`a`.`sRegDate` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`sRegDate`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `sRegDate`,(case when (`a`.`feeendtime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`feeendtime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `feeendtime`,

(case when (`a`.`iStatus` = _utf8'0') then _utf8'正常' when (`a`.`iStatus` = _utf8'1') then _utf8'锁定' when (`a`.`iStatus` = _utf8'2') then _utf8'欠费' when (`a`.`iStatus` = _utf8'') then _utf8'申请停机' else _utf8'' end) AS `iStatus`,

(case when (`a`.`PayType` = _utf8'0') then _utf8'免费' when (`a`.`PayType` = _utf8'2') then _utf8'小区网用户' when (`a`.`PayType` = _utf8'10') then _utf8'外部用户' else _utf8'' end) AS `PayType`,


`c`.`UserType` AS `sDh1`,`b`.`FeeName` AS `iFeeType`,

 

(case when (`a`.`PauseStartTime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`PauseStartTime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `PauseStartTime`,

(case when (`a`.`PauseStopTime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`PauseStopTime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `PauseStopTime`,

(case when (`a`.`AcctStartTime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`AcctStartTime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `AcctStartTime`,

(case when (`a`.`AcctStopTime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`AcctStopTime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `AcctStopTime`,

 

`a`.`speed` AS `speed`,

 

(case when (`a`.`idtype` = _utf8'7') then _utf8'身份证' when (`a`.`idtype` = _utf8'1') then _utf8'教职工' when (`a`.`idtype` = _utf8'2') then _utf8'本科生' when (`a`.`idtype` = _utf8'3') then _utf8'研究生' when (`a`.`idtype` = _utf8'4') then _utf8'离退生' when (`a`.`idtype` = _utf8'5') then _utf8'护照' when (`a`.`idtype` = _utf8'6') then _utf8'军官证' when (`a`.`idtype` = _utf8'8') then _utf8'其他' else _utf8'' end) AS `idtype`,

 

 

(case when (`a`.`iFeeTypeTime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`iFeeTypeTime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `iFeeTypeTime`,

 

`a`.`hth` AS `hth`

 

from ((`user_a` `a` left join `user_b` `b` on((`a`.`iFeeType` = `b`.`FeeCode`))) left join `user_c` `c` on((`c`.`TypeID` = `a`.`sDh1`)))

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值