title: Join two tables belong to two database in Elixir Ecto
body: <p>In Elixir, with Ecto, is it possible to join two different tables (in the same host) belonging to different two databases.</p>
  
  <p>There are two databases called <code>cloud</code> and <code>cloud_usage</code> in this query</p>
  
  <p>When I execute the query, which Repo should I use?</p>
  
  <p><code>Billing.CloudUsage.Repo.all(query)</code> </p>
  
  <p>or</p>
  
  <p><code>Billing.Cloud.Repo.all(query)</code></p>
  
  <pre><code>    query = from cucu in "cloud_usage.cloud_usage",
          inner_join: cv in "cloud.volumes", on: cucu.usage_id == cv.id,
            where: cucu.account_id == ^account_id,
            where: cucu.usage_id == 6,
            where: like(cucu.description, ^vol_description),
            where: cucu.start_date &gt;= ^start_datetime,
            where: cucu.start_date &lt;= ^end_datetime,
         group_by: cucu.usage_id,
         group_by: cucu.zone_id,
           select: {cucu.usage_id, cucu.zone_id, cucu.size, sum(cucu.raw_usage)}
  　　　result  = Billing.CloudUsage.Repo.all(query)
  </code></pre>
  
  <p>When I call the function I got the error</p>
  
  <pre><code>** (Mariaex.Error) (1146): Table 'cloud_usage.cloud_usage.cloud_usage' doesn't exist
  </code></pre>
  
  <p>I know why this happened. But If I use <code>Billing.Cloud.Repo.all(query)</code> , I think I can hardly retrieve the data in <code>cloud_usage.cloud_usage</code> table. Vice versa</p>
  
  <p>Reference:</p>
  
  <p><a href="https://stackoverflow.com/questions/5698378/mysql-join-between-tables-in-2-different-databases">MySQL -- join between tables in 2 different databases?</a></p>