【发布时间】:2013-10-14 13:27:12
【问题描述】:
我可以就如何更新视图提供建议吗?这是我创建的视图.. 但是由于存储的功能它不能更新,对吗?加入查询是否也不能更新?和 if 函数?请帮帮我..对不起我的英语。
CREATE
ALGORITHM = UNDEFINED
DEFINER = `root`@`localhost`
SQL SECURITY DEFINER
VIEW `view_attendance_dgv` AS
select
`tbl_stockholders`.`user_id` AS `user_id`,
`tbl_images`.`image_template` AS `Image Template`,
finger_name(`tbl_fingerprints`.`finger`) AS `Enrolled Finger`,
`tbl_users`.`last_name` AS `Last Name`,
`tbl_users`.`first_name` AS `First Name`,
`tbl_users`.`middle_name` AS `Middle Name`,
if((`tbl_stockholders`.`attendance_status` = 0),
'Absent',
'Present') AS `Attendance Status`,
if((`tbl_stockholders`.`voting_status` = 0),
'Not Voted',
'Voted') AS `Voting Status`
from
((((`tbl_stockholders`
join `tbl_shares` ON ((`tbl_stockholders`.`user_id` = `tbl_shares`.`user_id`)))
join `tbl_users` ON ((`tbl_stockholders`.`user_id` = `tbl_users`.`user_id`)))
join `tbl_images` ON ((`tbl_stockholders`.`user_id` = `tbl_images`.`user_id`)))
join `tbl_fingerprints` ON ((`tbl_stockholders`.`user_id` = `tbl_fingerprints`.`user_id`)))
order by `tbl_stockholders`.`user_id`
【问题讨论】:
-
请阅读此文档页面dev.mysql.com/doc/refman/5.6/en/view-updatability.html,特别注意
It is sometimes possible for a multiple-table view to be updatable, assuming that it can be processed with the MERGE algorithm. For this to work, the view must use an inner join (not an outer join or a UNION). Also, only a single table in the view definition can be updated, so the SET clause must name only columns from one of the tables in the view.