-
Three table join
Hi,
I have some troube with my queries
Here is how the table looks like:
S
_
snr(primary key)
sname
status
city
P
_
pnr(primary key)
pname
color
weight
city
SP
__
snr (primary + foreign key)
pnr (primary + foreign key)
qty
What I want to do is to find which suppliers(S) supply blue parts(P)
I know I have to join s, p, sp since I need all the tables. I also know I need to use where p = 'blue'
I tried this query:
select s.sname, p.pname
2 from s natural join sp natural join p
3 on sp.snr = s.snr
4 and sp.pnr = p.pnr
5 where p.color = 'blue'
ERROR at line 3:
ORA-00933: SQL command not properly ended
but is doesn't work.
I'm using Oracle 10g.
Please help me
-
Try:
select s.sname, p.pname
from s
join sp on sp.snr = s.snr
join p on sp.pnr = p.pnr
where p.color = 'blue'
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|