嘿我试图使用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'")"
如何获取两个表的列?
答案 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.*
应该为您提供所有属性