Execute Insert_all from a select

ecto
ecto-query
insert

#1

I need insert some information of a table in another table.
Is possible to do something like this code (that doesn’ t work) to execute only one query and not 2 separately?
Thanks

followers = from u in User,
            select: %{user_id: u.id, topic_id: ^topic.id},
            inner_join: a in Activity, on: [user_id: u.id],
            where: a.contest_id == ^topic.contest_id
              and a.type == 1
          Repo.insert_all(TopicUser, followers)

#2

The question becomes, how would you do this in normal SQL?

Once shown there then it can be translated to Ecto (or if it is simple with little to no possible typing issues in the future then just keep it as SQL). :slight_smile: