Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql column reference "id" is ambiguous

I tried the following select:

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

and I get the following error column reference id is ambiguous.

Thing is if I try the same SELECT but I only ask for name, and not for id also, it works. I'm new to this and maybe I am missing something obvious. Any suggestions?

Thanks.

like image 742
Fofole Avatar asked Mar 22 '12 11:03

Fofole


1 Answers

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_id where p2vg.people_id =0; 
like image 141
JScoobyCed Avatar answered Oct 11 '22 05:10

JScoobyCed