Elixir 如何从EXTO中的两个表中选择数据
我试图编写一个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
从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}