SQL to join to the best matching row

Posted by williamjones on Stack Overflow See other posts from Stack Overflow or by williamjones
Published on 2010-06-18T02:23:22Z Indexed on 2010/06/18 2:33 UTC
Read the original article Hit count: 334

Filed under:
|

I have a wiki system where there is a central table, Article, that has many Revisions in their own table. The Revisions each contain a created_at time and date column.

I want to update the Articles to contain a denormalized field sort_name from the most recent Revision's name field.

What SQL command can I issue to fill in each Article's sort_name field with its most recent Revision's name field?

For what it's worth, I'm on PostgreSQL.

© Stack Overflow or respective owner

Related posts about postgresql

Related posts about denormalization