[英]Update a large mysql table with data from another table
I have two tables 'Cast' and 'Roles'. 我有两个表“ Cast”和“ Roles”。 Table 'Cast' fields are Id, castName, castID, roleId.
表“投放”字段是Id,castName,castID,roleId。 Fields of table 'Roles' are Id, castId, role_Id
表“角色”的字段是Id,castId,role_Id
I want to update role_Id in table 'Roles' where it is null in this table and is equal to '1' in table 'Cast'. 我想更新表“ Roles”中的role_Id,其中该表中的null为空,并且等于表“ Cast”中的“ 1”。
This is what I wrote: 这是我写的:
UPDATE Roles
INNER JOIN Cast on (Cast.castID = Roles.castId)
SET Roles.role_Id = '2'
WHERE Roles.role_Id IS NULL AND Cast.roleId = '1';
Could someone help me to understand what is the problem with this query and how can I update the table 'Roles'? 有人可以帮助我了解此查询的问题是什么,如何更新表“ Roles”?
I puted Cast.roleId = '1'
condition at on clause 我在on子句中放置了
Cast.roleId = '1'
条件
UPDATE Roles
INNER JOIN Cast on
Cast.castID = Roles.castId AND Cast.roleId = '1'
SET Roles.role_Id = '2'
WHERE Roles.role_Id IS NULL;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.