Re: Join condition parsing puzzle

2018-08-26 Thread Mark Jeffcoat
On Thu, Aug 23, 2018 at 4:51 PM, Tom Lane wrote: > > Mark Jeffcoat writes: > > I would have claimed before seeing this example that it wasn't even > > grammatical; I thought the only legal place to write the ON clause was > > immediately after the JOIN. Apparently not. > > You read it as > > SEL

Re: Join condition parsing puzzle

2018-08-23 Thread Tom Lane
Mark Jeffcoat writes: > SELECT * > FROM relation_a > LEFT JOIN relation_b > JOIN relation_c > ON (relation_c.id_p = relation_b.id_p) > ON (relation_a.id_c = relation_b.id_c AND relation_a.id_v = relation_b.id_v); > I would have claimed before seeing this example that it wasn't even > grammatical;

Join condition parsing puzzle

2018-08-23 Thread Mark Jeffcoat
I'm looking at a query generated by SQLAlchemy. It works; Postgres is perfectly happy to run it, and it gives answers that make sense to the guy who wrote it. But I don't understand why it works. Stripped way down ... CREATE VIEW relation_a (id_c, id_v) AS VALUES (1, 20), (2, 21), (3, 22); CREA