Mysql 用临时表连接AR模型
为了创建临时表,我使用了 我需要加入我用AR模型创建的临时表。你知道如何做到这一点吗 以下是原始SQL查询:Mysql 用临时表连接AR模型,mysql,ruby-on-rails,ruby,activerecord,temp-tables,Mysql,Ruby On Rails,Ruby,Activerecord,Temp Tables,为了创建临时表,我使用了 我需要加入我用AR模型创建的临时表。你知道如何做到这一点吗 以下是原始SQL查询: SELECT * FROM `example1` as t1 JOIN `example2` as t2 on t1.`book_name` = t2.`book_name` and t1.`author` = t2.`author` and t1.`date`= t2.`date` 在本例中,示例1是通过temping gem创建的temp表,示例2是实际的AR模型。作为tempin
SELECT * FROM `example1` as t1 JOIN `example2` as t2 on t1.`book_name` = t2.`book_name` and t1.`author` = t2.`author` and t1.`date`= t2.`date`
在本例中,示例1是通过temping gem创建的temp表,示例2是实际的AR模型。作为temping创建AR对象,我想您可以使用以下内容:
Example1.joins("example2 ON example1.book_name = example2.book_name ... etc").find_all