Reputation: 3200
I have three tables as follows
user(username address)
profile(fname,lname,mobile)
details(performance,activity)
I want all information from the above three tables in one query
i.e. I want to make join of three tables for one common id field
I have the following query which retrives only two table fields
@details=User.find(:all,:joins => :profile,:select => "*")
How to do it for all three tables ???
Upvotes: 0
Views: 1789
Reputation: 438
This worked for me:
value_variable = 'hello world'
Member.joins(:person => [:workplace => [:business]]).where("businesses.name LIKE :value", value: "%#{value_variable}%")
NOTE: Tested on rails 3.2, 4.x, 5.x
Upvotes: 1
Reputation: 9700
Here's how this query would look:
@details = User.select('*').joins(:profile, :details).all
I'm not convinced this is actually a good way to do anything, but it should work.
Upvotes: 3