Skip to content

Instantly share code, notes, and snippets.

@jameslittle230
Created November 2, 2018 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameslittle230/18d83d350d74a197c39769e01a4a646d to your computer and use it in GitHub Desktop.
Save jameslittle230/18d83d350d74a197c39769e01a4a646d to your computer and use it in GitHub Desktop.
Almost-done query
select
article.id,
date,
title,
excerpt,
body
from
article LEFT JOIN (
select id, article_id, body, max(timestamp) from articlebody
group by article_id
ORDER BY timestamp DESC
limit 300
) articlebody ON article.id = articlebody.article_id
WHERE published = 1
ORDER BY date DESC
LIMIT 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment