MySQL case when用法

 实例如下:

CREATE ALGORITHM = UNDEFINED DEFINER = `xxx`@`%` SQL SECURITY DEFINER VIEW `v_finance_pay_group` AS SELECT
	`fpg`.`name` AS `name`,
	`fr`.`id` AS `room_id`,
	`fr`.`number_id` AS `number_id`,
	`fr`.`house_type_id` AS `house_type_id`,
	(
		CASE
		WHEN (`fr`.`house_type_id` = 51) THEN
			'廉租公寓'
		WHEN (`fr`.`house_type_id` = 52) THEN
			'写字楼'
		WHEN (`fr`.`house_type_id` = 53) THEN
			'公寓'
		WHEN (`fr`.`house_type_id` = 54) THEN
			'商铺'
		WHEN (`fr`.`house_type_id` = 103) THEN
			'排铺'
		WHEN (`fr`.`house_type_id` = 104) THEN
			'裙楼'
		WHEN (`fr`.`house_type_id` = 105) THEN
			'大Mall'
		ELSE
			'未知'
		END
	) AS `house_type_name`,
	`fpg`.`id` AS `pay_group_id`,
	`fpg`.`is_del` AS `pay_group_is_del`,
	`fr`.`is_del` AS `room_is_del`,
	`fr`.`name` AS `room_name`
FROM
	(
		(
			`finance_pay_group` `fpg`
			LEFT JOIN `finance_pay_group_binding` `fpgb` ON (
				(
					`fpg`.`id` = `fpgb`.`pay_group_id`
				)
			)
		)
		LEFT JOIN `finance_room` `fr` ON (
			(`fr`.`id` = `fpgb`.`room_id`)
		)
	)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值