How do I insert two table in one from?

The example is like this

def choose() do
from(u in User1, u2 in User2) ← got error
|> where([u, u2], u.id == u2.id)
|> Repo.all()

end

In sql it works like this

SELECT * FROM User1, User2
WHERE User1.ID = User2.ID

Why can’t I use 2 table in one from like sql?
Is there anything wrong?

Try this instead:

query = from u in User1,
join: u2 in User2,
on: u.id == u2.id

Repo.all(query)

This might work, joining the two?

1 Like

Thanks! I’ll try it!

def list_not_chosen_users(user) do
    from(u in User)
    |> join(:left, [u], u2 in User2, on: u.id != u2.id)
    |> where([u2],is_nill(u2.id)) <- It occurs error
    |> Repo.all()
  end

How do I put is_nill in that area? There are only answers about no pipelines.

Oh… my bad… it was a typo.

Did it work?