SQL query issues - how to find answer?

137 views Asked by At

Tables:

  • PERSON (ssn, Name)
  • Has_Visited (ssn, city)
  • Belongs_To (City, country)

Based on following information, create this question:

What is the name of the persons that have visited the city "London"?

2

There are 2 answers

0
akhil vangala On
Select p.Name from person p,has_visited hs 
where p.ssn= hs.ssn and hs.city= 'LONDON'
2
Mureinik On

Just use the in operator:

SELECT name
FROM   person
WHERE  ssn IN (SELECT ssn
               FROM   has_visited
               WHERE  city = 'London');