实例如下:
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`)
)
)