Please help me deal with a seemingly simple sql query, but which does not work, I have already tried all the options through JOIN and through variations in WHERE
Таблица User
| id | status | postId |
|---|---|---|
| 12345 | new | 55555 |
| 23456 | ready | 55555 |
| 34567 | done | 77777 |
I need to output postId if it has status = new And status = ready. postId = 55555 should be output My option:
SELECT
postId
FROM User
WHERE postId IN (55555, 77777)
AND (status = new AND status = ready)
GROUP BY postId
But it does not work because of a contradiction (status = new AND status = ready), it only works (status = new OR status = ready), but such a condition does not suit me, it needs to be strictly both new and ready. MySql.
I also have SQL with nested request:
SELECT postId FROM User WHERE status = ready AND postId IN
(SELECT postId FROM User WHERE status = new )
It works, but if I need process more than 2 status the request becomes more complicated