Sojo Sojo - 6 months ago 5
SQL Question

Missing from clause in a valid inner join request

I have this:

SELECT tbl1.* as tbl1 from table1
inner join table2 as tbl2
on tbl1.id = tbl2.table1_id
where tbl2.something = xxx;


why does it throw an exception

ERROR: missing FROM-clause entry for table "tbl1"
LINE 3: on tbl1.id = tbl2.table1_id
^

Answer

it should be:

SELECT tbl1.* from table1 as tbl1 
inner join table2 as tbl2
on tbl1.id = tbl2.table1_id
where tbl2.something = xxx;
Comments