Hacker News new | past | comments | ask | show | jobs | submit login

As someone who only works now and then with Postgres, this is what made it click for me:

"Loosely, it means that a LATERAL join is like a SQL foreach loop, in which PostgreSQL will iterate over each row in a result set and evaluate a subquery using that row as a parameter."




Sounds like what Oracle calls a "correlated subquery" is it the same thing?


No, Postgres has supported those for a long time. For example:

    SELECT *
    FROM   employees e
    WHERE  EXISTS (SELECT 1
                   FROM   employee_projects ep
                   WHERE  ep.employee_id = e.id
                   AND    ep.project_id = 5)
    ;
This new feature is a lot like correlated subqueries except you can put that nested SELECT into the FROM clause and still access the employees table.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: