Article.all("tags.id" => 2) & Article.all("tags.id" => 3) should work. It
actually produces 3 queries but I don't think this will work longer then
your one.

2010/7/7 deco <[email protected]>

> How would I get datamapper to produce a query like this?
>
> In this example I'm attempting to return the articles that have the
> tags with id 2 and 3.
>
>
> SELECT * FROM `articles`
> JOIN `article_tags` ON article_id = `articles`.`id`
> WHERE `tag_id` = 2
> AND EXISTS(SELECT * FROM article_tags WHERE tag_id = 3 AND article_id
> = `articles`.`id`)
>
> - **  Row 4 could appear several times depending on the number of tags
> being searched.
>
>
> TABLE: tags
> id, tagtext
>
> TABLE: articles
> id, body, title
>
> TABLE: article_tags
> id, tag_id, article_id
>
> --
> You received this message because you are subscribed to the Google Groups
> "DataMapper" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<datamapper%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/datamapper?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to