0

I'm new to postgreSQL. I'm trying to execute some simple queries but i'm having an error i'm stuck with. Following is a simple query

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';

The error that is being thrown while executing this query is

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

I couldn't understand this error. Need some help.

2 Answers 2

3

Did you mean

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';

? Probably not. Probably you meant:

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';
Sign up to request clarification or add additional context in comments.

Comments

1

The join of works lacks a join condition. Follow it with on or using.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.