Skip to content

Instantly share code, notes, and snippets.

@rossriley
Created October 26, 2015 21:08
Show Gist options
  • Save rossriley/eeaa42e10b589b746ea0 to your computer and use it in GitHub Desktop.
Save rossriley/eeaa42e10b589b746ea0 to your computer and use it in GitHub Desktop.
SELECT content.*, GROUP_CONCAT(DISTINCT entries.to_id) as entries FROM bolt_showcases content LEFT JOIN bolt_relations entries ON ((content.id = entries.from_id) AND (entries.from_contenttype = :boltname) AND (entries.to_contenttype = :field)) OR ((content.id = entries.to_id) AND (entries.to_contenttype = :boltname) AND (entries.from_contenttype = :field)) GROUP BY content.id
SELECT content.*, GROUP_CONCAT(DISTINCT entries.to_id) as entries FROM bolt_showcases content LEFT JOIN bolt_relations entries ON content.id = entries.from_id AND entries.from_contenttype='showcases' AND entries.to_contenttype='entries' GROUP BY content.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment