我是postgreSQL的新手。我正在尝试执行一些简单的查询,但我遇到了一个错误,我一直坚持。以下是一个简单的查询
select e.street, e.city
from employee e join works w join managers m on e.Lastname=w.Lastname
and w.Lastname=m.MLastname
where w.companyname='Union Pacific';
执行此查询时抛出的错误是
ERROR: syntax error at or near "where"
LINE 4: where w.companyname='Union Pacific';
^
********** Error **********
ERROR: syntax error at or near "where"
SQL state: 42601
Character: 124
我无法理解这个错误。需要一些帮助。
答案 0 :(得分:3)
你的意思是
select e.street, e.city
from employee e
join works w
join managers m on (e.Lastname=w.Lastname and w.Lastname=m.MLastname)
where w.companyname='Union Pacific';
?可能不是。可能你的意思是:
select e.street, e.city
from works w
join employee e on w.Lastname=e.Lastname
join managers m on w.Lastname=m.MLastname
where w.companyname='Union Pacific';
答案 1 :(得分:1)
works
的联接缺少连接条件。通过on
或using
跟进。