Quantcast
Channel: Planet PostgreSQL
Viewing all articles
Browse latest Browse all 9825

Steven Pousty: Iterators in PostgreSQL with Lateral Joins

$
0
0

There you are writing some SQL, having a great time. Uh oh, you need to iterate over each item in a result set and apply a function. You think, "Now I am going to have to write a stored procedure." Well today's post will give you an alternative by using lateral joins in Postgres

 Lateral pass.... See what I did there?

What is a Lateral Join?

You are probably familiar with normal database joins, which are usually used to match up a column in one table with a column in another table to bring the data from both tables together. When the keyword LATERAL is added to your join, the output will now apply the right hand part of the join to every record in the left part of the join.


Viewing all articles
Browse latest Browse all 9825

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>