Skip to content

Instantly share code, notes, and snippets.

Created February 19, 2009 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/66776 to your computer and use it in GitHub Desktop.
Save anonymous/66776 to your computer and use it in GitHub Desktop.
The query:
select episodes.id from episodes
left outer join links on links.link_id = episodes.link_id
where episodes.link_id > 0 and links.link_id is NULL
The attempt:
Episode.find(:all, :include => :link, :conditions => "links.link_id = episodes.link_id")
Produces:
SELECT episodes.id FROM "episodes"
LEFT OUTER JOIN "links" ON "links".link_id = "episodes".link_id
WHERE (links.link_id = episodes.link_id)
It's close! How can I change Rails's WHERE clause to mine above?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment