# Day.find\_all\_with\_appointments - INNER JOIN

**URL:** <https://www.ruby-forum.com/t/day-find-all-with-appointments-inner-join/94932>\
**Category:** Rails\
**Created:** [January 10, 2006, 6:51pm UTC](https://www.ruby-forum.com/t/day-find-all-with-appointments-inner-join/94932 "2006-01-10T18:51:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aravet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/49beb7/32.png) [@aravet](https://www.ruby-forum.com/u/aravet)\
**Post date:** [January 10, 2006, 6:51pm UTC](https://www.ruby-forum.com/t/day-find-all-with-appointments-inner-join/94932/1 "2006-01-10T18:51:11Z")

</div>

Hi list,

Is there a better/simpler way to code an inner join, than the 4 lines  
below:

```
 class Day < Foo

     def self.find_all_with_appointments (*args)
         find :all,
         { :select => 'distinct foos.*',
         	:joins => 'INNER JOIN appointments ON days.appointment_id

```

= foos.id’  
}.merge (extract\_options\_from\_args!(args))

```
     end
     has_many :results , :class_name => "Result", :foreign_key

```

=\> “event\_id”  
end

:include doesn’t help here, as it produces an outer join.

Alain
