Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在mysql中更新查询内部视图_Mysql - Fatal编程技术网

在mysql中更新查询内部视图

在mysql中更新查询内部视图,mysql,Mysql,我们可以将更新查询放在视图中吗?如果是,请告诉我为什么会出现上述错误。我想增加工资并使用view显示它。为什么不这样做 mysql> create view incremented_salary as -> update employee set salary=salary*1.1; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to y

我们可以将更新查询放在视图中吗?如果是,请告诉我为什么会出现上述错误。我想增加工资并使用view显示它。

为什么不这样做

mysql> create view incremented_salary as
    -> update employee set salary=salary*1.1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual 
that corresponds to your MySQL server version for the right syntax to use near 
'update employee set salary=salary*1.1' at line 2
视图不修改表的值

它们为您提供了一个关于它们的新视图-例如,连接多个表,聚合,或者基于表值重新计算一些值

如果你尝试的方法有效,那么每次你查看数据时,它的价值都会增加

create view incremented_salary as
  select salary*1.1 from wahtevertable