Say for example I have a table named user with login column with jsonb type and the record looks like this:
user
name | login
-------------
test1 | {"byDate":[{"date":"2020-01-01"},{"date":"2020-01-02"},{"date":"2020-01-03"},]}
test2 | {"byDate":[{"date":"2020-01-02"},{"date":"2020-01-03"},{"date":"2020-01-04"},]}
How do I SELECT (with WHERE clause) to include both date '2020-01-01' and '2020-01-02'?
For one date, I can do:
SELECT *
FROM "user"
WHERE "login" @> '{"byDate":[{"date": "2020-01-01"}]}'
Can I use some sort of IN to select both '2020-01-01' and '2020-01-02'? Or do I just use OR, ex:
SELECT *
FROM "user"
WHERE "login" @> '{"byDate":[{"date": "2020-01-01"}]}'
OR "login" @> '{"byDate":[{"date": "2020-01-02"}]}'
I want the result to be an OR product, ex: I use '2020-01-01' OR '2020-01-03' both test1 AND test2 will show up in the result.
Any help would be much appreciated.
Thanks