Skip to content

Instantly share code, notes, and snippets.

@loe
Created August 15, 2008 21:57
Show Gist options
  • Save loe/5662 to your computer and use it in GitHub Desktop.
Save loe/5662 to your computer and use it in GitHub Desktop.
SELECT content_items.id id, 'ContentItem' AS class, 7 AS class_id, CAST(GROUP_CONCAT(DISTINCT comments.body SEPARATOR ' ') AS CHAR) AS comments, UNIX_TIMESTAMP(content_items.created_at) AS created_at, CONCAT_WS(' ', content_items.description, content_items.filename) AS description, content_items.title AS title, UNIX_TIMESTAMP(content_items.updated_at) AS updated_at FROM content_items JOIN (comments, discussions) ON (content_items.id = discussions.target_id AND discussions.target_type = 'ContentItem' AND comments.discussion_id = discussions.id) GROUP BY content_items.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment