如何在 MySQL 中执行以下操作:
UPDATE PartTbl SET aFlag = 0
WHERE PartId = (SELECT PartId FROM CategoryTbl WHERE cat = 100)
如何在 MySQL 中执行以下操作:
UPDATE PartTbl SET aFlag = 0
WHERE PartId = (SELECT PartId FROM CategoryTbl WHERE cat = 100)
UPDATE PartTbl SET aFlag = 0
WHERE PartId IN (SELECT PartId FROM CategoryTbl WHERE cat = 100)
只需在 WHERE 子句中使用"IN"
而不是运算符或使用以下代码:"="
UPDATE A
SET aFlag = 0
From PartTbl As A
Inner Join
CategoryTbl As B
On A.PartId = B.PartId
WHERE B.cat = 100
UPDATE PartTbl pt SET aFlag = 0
WHERE exists (
SELECT PartId FROM CategoryTbl ct
WHERE cat = 100 and pt.partId = ct.partId)