Re: sql query?
Date: Fri, 22 Feb 2002 20:46:42 +0000
Message-ID: <3C76AE32.7FA82BA8_at_dunelm.org.uk>
> "D'laila Pereira" <dpereira_at_students.uiuc.edu> wrote in message
> news:Pine.GSO.4.31.0202201846420.15681-100000_at_ux5.cso.uiuc.edu...
> >
> > Given the following tables
> > tourist(tid,tname)
> > travel(tid,city, arrivaldate,stayindays)
> >
> > find, the names of the tourists who have visited "Detroit" and "Miami" but
> > no other cities.
> >
> > Any hints on how to solve this one?
> >
chad baker wrote:
>
> select tname from tourist where tid in (select tid from travel where city =
> 'Detroit' or city = 'Miami')
>
Bzzzt.
D'laila said 'no other cities'.
You need:
select tname from tourist where
(tid in (select tid from travel where city = 'Detroit' or city = 'Miami'))
and
(tid not in (select tid from travel where city <> 'Detroit' and city <> 'Miami'));
Regards,
Kieran
Received on Fri Feb 22 2002 - 21:46:42 CET