# Automatic field update

**URL:** <https://forum.elixirforum.com/t/automatic-field-update/13363>\
**Category:** Questions\
**Tags:** phoenix\
**Created:** [March 28, 2018, 4:36pm UTC](https://forum.elixirforum.com/t/automatic-field-update/13363 "2018-03-28T16:36:16Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![gilbertosj](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/g/48db29/32.png) [@gilbertosj](https://forum.elixirforum.com/u/gilbertosj)\
**Post date:** [March 30, 2018, 3:39pm UTC](https://forum.elixirforum.com/t/automatic-field-update/13363/4 "2018-03-30T15:39:36Z")

</div>

The problem I’m having is …  
Select 2 only recognizes the first line of select 1 …  
Type…

Result of select 1 = Brings all the results of a column  
Result of select 2 = You are only returning the result of the first row of select 1 …

I made some adjustments, but to no avail …

select 1: `cod_cliente = Repo.all(from(c in Cliente, select: {c.fantasia_cliente, c.cod_cliente}, order_by: [c.fantasia_cliente]))`

select 2: `tipo_cliente = Repo.all(from(c in Cliente, select: c.tipo_cliente, where: c.cod_cliente == ^elem(List.first(cod_cliente),1))) |> List.first()`

In my form.html …  
I’m asking him to get select 2 and update the field …  
More like always, only the result of the first line of select 1 returns me

How should it be?  
In javascript, it will return me the full 1 select tbm! …  
I know I can not, escape from javascript …  
But I’m starting to think my query is wrong.

---

_[View the full topic](https://forum.elixirforum.com/t/automatic-field-update/13363)._
