【发布时间】:2018-11-25 22:17:37
【问题描述】:
我有 2 张桌子,users 和 profiles。如果users.emails 在列表('email1','email2',...) 中,我想将profiles.verified 设置为true。
受updating table rows in postgres using subquery 等其他 SO 线程的启发,我一直在尝试做类似的事情,
UPDATE
profiles p1
SET
verified = true
FROM
profiles p2
INNER JOIN users u1 on u1.id = p2.user_id
WHERE
u1.email in ('email1','email2',...)
但它只是将profiles 中的所有记录的profiles.verified 更新为true。
如果profile 记录与带有指定列表中的电子邮件的users 记录相关,我如何才能只更新它们?
【问题讨论】:
标签: sql postgresql join sql-update