Concatenate String inside a Select in Query

Hi, I’m trying to concatenate two variables in the select field inside a query. Is this possible? a in Apple, where: == 1, select: %{name: <> a.color})

I’ve tried Enum.join, and the error seems to be the same

1 Like

The concatenation in a select expression needs to be understood by Ecto and your target database. In this case, the Elixir string concatenation operator is not interpreted by Ecto (ie not translated into the required underlying SQL). This link may help (tldr; use a fragment with the SQL concat function):

Thanks! That was the answer