-3

我可以就如何更新视图提供建议吗?这是我创建的视图.. 但是由于存储的功能它不能更新,对吗?加入查询是否也不能更新?和 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`
4

1 回答 1

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

是的,我相信您的查询,您对JOINs 和函数的使用使您的视图不可更新。

于 2013-10-07T20:29:33.060 回答