What is the equivalent Syntax for Outer Apply in PostgreSQL [duplicate]
It is a lateral join:
SELECT table1.col1, table1.col2, Supp.ID, Supp.SupplierFROM SIS_PRS table1 LEFT JOIN LATERAL (SELECT ID, SupplierName FROM table2 WHERE table2.ID = table1.SupplierID FETCH FIRST 1 ROW ONLY ) Supp ON true;
However, you can come pretty close in either database with just a correlated subquery:
SELECT table1.col1, table1.col2, table1.SupplierID, (SELECT Name FROM table2 WHERE table2.ID = table1.SupplierID FETCH FIRST 1 ROW ONLY ) as SupplierNameFROM SIS_PRS table1;
Also note that in both databases, fetching one row with no ORDER BY
is suspicious.