Query syntax

Let’s start with the basics. We’ll take a quick look at Ecto’s query syntax, then write simple queries, including some that integrate user input.

The Query module uses Elixir macros to create a DSL (domain-specific language) that sits right in our Elixir code. The DSL syntax feels like Elixir, but it’s a little more fluid and makes writing queries feel natural.

SQL based query

For example, here’s a SQL query based on the data model in our sample application.

Get hands-on with 1200+ tech skills courses.