我可以就如何更新视图提供建议吗?这是我创建的视图..但由于存储的功能,它不可更新吗?连接查询是否也无法更新?和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`
答案 0 :(得分:2)
http://dev.mysql.com/doc/refman/5.6/en/create-view.html
对于可更新的视图,视图中的行与基础表中的行之间必须存在一对一的关系。还有一些其他构造使视图不可更新。
更多细节在这里:
http://dev.mysql.com/doc/refman/5.6/en/view-updatability.html
是的,我相信您的查询,您使用JOIN
和函数会使您的视图无法更新。