Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.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 错误1442:Can';t更新存储函数/触发器中的表_Mysql_Sql_Mysql Error 1442 - Fatal编程技术网

Mysql 错误1442:Can';t更新存储函数/触发器中的表

Mysql 错误1442:Can';t更新存储函数/触发器中的表,mysql,sql,mysql-error-1442,Mysql,Sql,Mysql Error 1442,我正在尝试更新第三方应用程序中的数据库。以下是受影响的两个表的架构: Table 'camera' columns: deviceID, connectionState Table 'cameraRecording' columns: deviceID, recordToVolumeID 我尝试了这两个查询,但收到了相同的错误 mysql> update cameraRecording SET recordToVolumeID='STRING'

我正在尝试更新第三方应用程序中的数据库。以下是受影响的两个表的架构:

Table 'camera' 
columns:  deviceID, connectionState

Table 'cameraRecording' 
columns: deviceID, recordToVolumeID 
我尝试了这两个查询,但收到了相同的错误

mysql> update cameraRecording 
       SET recordToVolumeID='STRING' 
       WHERE deviceID 
       IN (select deviceID from camera WHERE connectionState=1);

ERROR 1442 (HY000): Can't update table 'camera' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.


我不是SQL方面的专家,也不经常使用它,但我很确定这应该是可行的。我猜应用程序已经设置了触发器或函数。。。有没有办法完成这项任务?我读过很多其他有错误的帖子,但大多数都涉及到他们试图创建一个触发器

您能否声明一个变量,然后使用该值

DECLARE @id int;
SELECT @id = deviceID from camera WHERE connectionState=1;

update cameraRecording 
SET recordToVolumeID='STRING' 
WHERE deviceID = @id;
DECLARE @id int;
SELECT @id = deviceID from camera WHERE connectionState=1;

update cameraRecording 
SET recordToVolumeID='STRING' 
WHERE deviceID = @id;