近日工做碰到一個PG error missing FROM-clause entry for table "t",這個錯誤基本上出如今選擇列或者where語句後面引用了t2的表可是在from 後面並無對應的表名。測試以下:sql
select t.* from dual;
select * from dual where t.id = ?
這類錯誤很好查清,找到對應的t,看下對應有沒有表別名,若是沒有,則加上,以下:測試
select t.* from dual t; select * from dual t where t.id = ?;