Query pulls an error by ambiguous column

3

Good morning I'm making a query in postgress and it throws an error:

  

"ERROR: the reference to the column" num_request "is ambiguous LINE   4: WHERE num_request in (3,6,9); ",

select * from area
inner join empleado on area.num_solicitud = empleado.num_solicitud
inner join bien on area.num_solicitud = bien.num_solicitud
WHERE num_solicitud in (3,6,9);
    
asked by richard herrera 04.01.2019 в 14:38
source

1 answer

3

What is happening to you is that this field has the same name in two or more tables in the query. You have to specify which table is the field num_solicitud.

select * from area
inner join empleado on area.num_solicitud = empleado.num_solicitud
inner join bien on area.num_solicitud = bien.num_solicitud
WHERE tabla.num_solicitud in (3,6,9);

I would advise seniors to add an alias to your tables, to make it easier to reference them.

select * from area a
inner join empleado emp on area.num_solicitud = empleado.num_solicitud
inner join bien b on area.num_solicitud = bien.num_solicitud

Greetings.

    
answered by 04.01.2019 / 14:42
source