Using PostgreSQL's DISTINCT ON with multi-table joins can silently return wrong data when both tables share a column name. This article dissects the problem and presents the two-phase subquery fix: first find matching IDs via join, then query the target table directly to avoid column ambiguity.