Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Simple SQL Question
Hello,
For the first problem:
select cname from company where city in (select city from company where cname = "Bank of Trade");
For the second problem:
select city from company c, manages m where city in (select e.ename from employee e, manages m, company c where e.eid=m.eid and e.city=c.city) and c.bid=m.bid;
We get a match on the employee id and the manager id so that when we match the city where the employee lives with the city that the company is located, we retrieve the manager that lives and manages in the same city.
I hope that helps you.....
Vinh Duong wrote:
> Hi,
>
> I have the following tables:
>
> Employee (eid, ename, street, city)
> Works (eid, bid, cname,salary)
> Company (bid, cname,city)
> Manages (eid, mid, bid, cname)
>
> A company, which is uniquely identified by its cname, may have branches
> (indicated by bid) in more than one city.
>
> Help me the write TWO appropriate queries that each satisfy the following
> requirements:
>
> 1- Find the names of companies that are located IN EVERY CITY in which 'Bank
> of Trade' is located.
>
> 2-Make a list of the cities which have one of its residents as a manger IN
> EVERY COMPANY located in the city.
>
> Gracias,
>
> Vinh
> Montreal
Received on Mon Mar 20 2000 - 00:22:00 CST
![]() |
![]() |