Hi,
I have 2 tables as follows:-
taggings | |stores | | tags |
-----------------| |---------------| |------------|
–tag_id | |–store_id | |tag_id |
–store_id | |–store_name | |tag_name |
–user_id | |---------------| |------------|
-----------------|
Now I want to execute followin sql query on above tables:-
“select name from tags where tag_id in (select tag_id from taggings
where store_id in (select store_id from stores where citylist like
‘%1%’)) ;”
I am able to get proper result using this sql query. But how should i
write same in query ruby inside my controller/model of tags table?
i.e Tag.find(:all, :conditions=>…
What will be conditions in above ruby statement?
Please tell me ?
Thanx in advance.
Prash
Anyways,
I solved it by direct writing SQL statement into one of my models…
Now its working fine…
![:slight_smile: :slight_smile:](/images/emoji/twitter/slight_smile.png?v=6)
Pras
Prashant T. wrote:
Hi,
I have 2 tables as follows:-
taggings | |stores | | tags |
-----------------| |---------------| |------------|
–tag_id | |–store_id | |tag_id |
–store_id | |–store_name | |tag_name |
–user_id | |---------------| |------------|
-----------------|
Now I want to execute followin sql query on above tables:-
“select name from tags where tag_id in (select tag_id from taggings
where store_id in (select store_id from stores where citylist like
‘%1%’)) ;”
I am able to get proper result using this sql query. But how should i
write same in query ruby inside my controller/model of tags table?
i.e Tag.find(:all, :conditions=>…
What will be conditions in above ruby statement?
Please tell me ?
Thanx in advance.
Prash