# Find all items which have these tags

**URL:** <https://www.ruby-forum.com/t/find-all-items-which-have-these-tags/135164>\
**Category:** Rails\
**Created:** [April 18, 2008, 6:10pm UTC](https://www.ruby-forum.com/t/find-all-items-which-have-these-tags/135164 "2008-04-18T18:10:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tobi\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea666f/32.png) [@Tobi\_R](https://www.ruby-forum.com/u/Tobi_R)\
**Post date:** [April 18, 2008, 6:10pm UTC](https://www.ruby-forum.com/t/find-all-items-which-have-these-tags/135164/1 "2008-04-18T18:10:08Z")

</div>

Hi

This works:  
Item.find(:all, :include =\> ‘tags’, :conditions =\> [“tags.name =  
?”,“Rainproof”])

This works as well:  
Item.find(:all, :include =\> ‘tags’, :conditions =\> “tags.name in  
(‘Rainproof’,‘Bowl’)”)  
(Here without substitution.)

How to find the items which have a tag with name “Rainproof” AND a tag  
with name “Bowl”?

Tobi

–  
[http://www.rubynaut.com/](http://www.rubynaut.com/)

---

<div class="post-metadata">

**Author:** ![Tobi\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea666f/32.png) [@Tobi\_R](https://www.ruby-forum.com/u/Tobi_R)\
**Post date:** [April 18, 2008, 7:39pm UTC](https://www.ruby-forum.com/t/find-all-items-which-have-these-tags/135164/2 "2008-04-18T19:39:56Z")

</div>

Tobi R. wrote:

> Hi
> 
> This works:  
> Item.find(:all, :include =\> ‘tags’, :conditions =\> [“tags.name =  
> ?”,“Rainproof”])
> 
> This works as well:  
> Item.find(:all, :include =\> ‘tags’, :conditions =\> “tags.name in  
> (‘Rainproof’,‘Bowl’)”)  
> (Here without substitution.)
> 
> How to find the items which have a tag with name “Rainproof” AND a tag  
> with name “Bowl”?

Not sure if this will work, as I’m not very good at SQL anymore…

Item.find(:all, :include =\> :tags, :conditions =\> [ 'tags.name = ? AND  
tags.name = ? ], ‘Rainproof’, ‘Bowl’ ])
