# OR conditions on has\_and\_belongs\_to\_many?

**URL:** <https://www.ruby-forum.com/t/or-conditions-on-has-and-belongs-to-many/175638>\
**Category:** Rails\
**Created:** [September 16, 2009, 10:36pm UTC](https://www.ruby-forum.com/t/or-conditions-on-has-and-belongs-to-many/175638 "2009-09-16T22:36:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [September 16, 2009, 10:36pm UTC](https://www.ruby-forum.com/t/or-conditions-on-has-and-belongs-to-many/175638/1 "2009-09-16T22:36:23Z")

</div>

Hi,

I wonder how I can insert “OR” in has\_and\_belongs\_to\_many conditions?

Code:  
has\_and\_belongs\_to\_many :projects, :conditions =\>  
[“projects\_users.user\_id = 0”]

Console:  
user.projects

SQL:  
Project Load (0.3ms) … WHERE (“projects\_users”.user\_id = 1 AND  
(projects\_users.user\_id = 0))

I wonder if I can change AND to OR

Thanks for help 😃

---

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [September 16, 2009, 10:37pm UTC](https://www.ruby-forum.com/t/or-conditions-on-has-and-belongs-to-many/175638/2 "2009-09-16T22:37:51Z")

</div>

I know I can do it with LIKE 🙂
