我有一张表用户
+----------+----------+
| ID_EMP | isActive |
+----------+----------+
| 100 + 1 +
| 101 + 1 +
+----------+----------+
和一个表UsersInfo
+----------+------------+
| ID_EMP | FRDATE |
+----------+------------+
| 100 + null +
| 101 + 2019-10-10 +
+----------+------------+
当不为空时,我尝试Users.isActive
用 0更新列。UsersInfo.FRDATE
我阅读了类似的问题并以以下查询结束,它没有按预期工作,因为它正在更新所有列0
UPDATE [dbMyDB].[dbo].[Users]
SET [dbMyDB].[dbo].[Users].[isActive] = 0
FROM [dbMyDB].[dbo].[Users] USERS
INNER JOIN
[dbMyDB].[dbo].[UsersInfo] INFO
ON USERS.ID_EMP = INFO.ID_EMP
WHERE EXISTS
(
SELECT FRDATE FROM [dbMyDB].[dbo].[UsersInfo]
WHERE FRDATE IS NOT NULL
)
我缺少什么?谢谢!
?