Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.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
Elixir 如何从EXTO中的两个表中选择数据_Elixir_Ecto - Fatal编程技术网

Elixir 如何从EXTO中的两个表中选择数据

Elixir 如何从EXTO中的两个表中选择数据,elixir,ecto,Elixir,Ecto,我试图编写一个EXTO查询,它将同时从两个表中选择数据。像从table1t1,table2t2中选择t1.*,t2.*,其中t1.id=1和t2.id=2我找不到解决方案,找到了编写原始SQL的唯一方法,看起来不太好 类似于variant-使用预加载,但它需要生成额外的查询 comments_query = from c in Comment, order_by: c.published_at Repo.all from p in Post, preload: [comments: ^comme

我试图编写一个EXTO查询,它将同时从两个表中选择数据。像
从table1t1,table2t2中选择t1.*,t2.*,其中t1.id=1和t2.id=2
我找不到解决方案,找到了编写原始SQL的唯一方法,看起来不太好

类似于variant-使用预加载,但它需要生成额外的查询

comments_query = from c in Comment, order_by: c.published_at
Repo.all from p in Post, preload: [comments: ^comments_query]

谢谢你的任何想法

试试这个来自exto.Query的方法

from t1 in Table1,
   join: t2 in Table2, on: t1.t2_id == t2.id,
   select: {t1.title, t2.text}