连接操作不会给出两个表的列

时间:2012-02-06 11:48:00

标签: ruby-on-rails ruby database activerecord

嘿我试图使用rails的find_by_sql方法连接两个表,但我没有得到'fb_ppl_pages'表的列:

"FbPage.find_by_sql("select * from fb_pages as t1 join fb_ppl_pages as t2 on t1.user_id=t2.user_id where t1.category='community'")"

如何获取两个表的列?

1 个答案:

答案 0 :(得分:0)

"FbPage.find_by_sql("select fb_pages.*,fb_ppl_pages.*  from fb_pages as t1 join fb_ppl_pages as t2 on t1.user_id=t2.user_id where t1.category='community'")"

选择fb_pages.*,fb_ppl_pages.*应该为您提供所有属性