创建一个WHERE或IN postgres

时间:2016-03-03 08:14:07

标签: mysql sql database postgresql psql

现在我有了查询

DELETE FROM connections
WHERE "user_b_id" IN
(SELECT "id"
FROM   "users"
WHERE  'dharness.student@gmail.com'="email")

但我真正想要的是

WHERE "user_b_id" OR "user_a_id" IN ...

但我无法弄清楚如何做到这一点。这有运营商吗?

1 个答案:

答案 0 :(得分:3)

如果users.email是唯一的,您可以写

WHERE (SELECT id FROM users 
       WHERE email = 'dharness.student@gmail.com') 
   IN (user_b_id , user_a_id)