I am running a query like this:
SELECT distinct me.*
FROM me
LEFT JOIN has_things ON has_things.me_id = me.id
LEFT JOIN has_refs ON has_refs.thing_id = has_things.thing_id
WHERE
has_refs.ref_id = 456
AND me.id=123;
In the first variant, I omit the last line AND me.id = 123
and get 0 rows while in the second variant I include that line and get 1 row.
In another variant where the last line is AND me.id >= 123
, I get 0 rows.
I am using psql
to query the database.
What am I missing, and how can I fix this?
I thought AND
conditions can only reduce the number of matches.
Does anyone know of such PostgreSQL bugs where rows just disappear or vanish, maybe with links to bug tickets or something?
Seems related to my other question:
How can PDO not return a row which pg_query() does?