Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 用临时表连接AR模型_Mysql_Ruby On Rails_Ruby_Activerecord_Temp Tables - Fatal编程技术网

Mysql 用临时表连接AR模型

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

为了创建临时表,我使用了

我需要加入我用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模型。

作为temping创建AR对象,我想您可以使用以下内容:

Example1.joins("example2 ON example1.book_name = example2.book_name ... etc").find_all