首页 > 代码库 > 记录一个mysql的case when用法

记录一个mysql的case when用法

SELECT wle.*, 		CASE		WHEN ‘2017-08-10 14:00:00‘ > wle.et THEN ‘回看‘		WHEN wle.st >= ‘2017-08-10 14:00:00‘ AND ‘2017-08-10 14:00:00‘ < wle.et THEN ‘直播中‘		WHEN wle.st > ‘2017-08-10 14:00:00‘ < wle.et AND (wles.statusx IS NULL OR wles.statusx != ‘1‘) THEN ‘预约‘		WHEN wle.st >‘2017-08-10 14:00:00‘ < wle.et AND wles.statusx = ‘1‘ THEN ‘巳预约‘		END statusx	FROM wsp_live_epg wle LEFT JOIN wsp_live_epg_subscribe wles ON 	(wle.id = wles.epg_id AND wles.user_id = ‘5l3y7yJwUpN4pdtjCFZYBpYFOt54Hfpz‘)	WHERE wle.live_tv_id = 9		AND wle.dt = ‘2017-08-10‘

  技术分享

 

记录一个mysql的case when用法