Execute Queries

Learn how to execute queries in Ecto on the same pattern as SQL.

We'll cover the following

Run SQL queries

In this lesson, we’ll look at how to run queries. Inserting, updating, and deleting are helpful, but queries are the real meat and potatoes of most database-backed applications. So how do we use them?

Note: Ecto provides an elegant and powerful query interface in the Query module. It’s worth pointing out that if you’re a fan of using raw SQL for your queries, you have that option.

The Ecto.Adapters.SQL module has a function called query that will take good old-fashioned SQL, like so.

Get hands-on with 1200+ tech skills courses.