Postgresql column reference "id" is ambiguous Postgresql column reference "id" is ambiguous postgresql postgresql

Postgresql column reference "id" is ambiguous


You need the table name/alias in the SELECT part (maybe (vg.id, name)) :

SELECT (vg.id, name) FROM v_groups vg inner join people2v_groups p2vg on vg.id = p2vg.v_group_idwhere p2vg.people_id =0;


I suppose your p2vg table has also an id field , in that case , postgres cannot find if the id in the SELECT refers to vg or p2vg.

you should use SELECT(vg.id,vg.name) to remove ambiguity


SELECT (vg.id, name) FROM v_groups vg INNER JOIN people2v_groups p2vg ON vg.id = p2vg.v_group_idWHERE p2vg.people_id = 0;