GISQ: Tutorial One: Notes 3
A Gentle
Introduction
to
SQL
Tutorial One
Notes 3
CIA World Factbook
Using nested select statements
The result of a SELECT statement may be used as a value in another
statement. For example the statement SELECT region FROM cia WHERE
name = 'Brazil' evaluates to 'South America' so we can use this
value to obtain a list of all countries in the same region as 'Brazil'
SELECT name FROM cia WHERE region =
(SELECT region FROM cia WHERE name = 'Brazil')
Note that this is not the same thing as a join.
Observe the tables which result from each of the following
SELECT name FROM cia
WHERE region = (SELECT region FROM cia WHERE name = 'Belarus')
The countries in the same region as Belarus.
name
Armenia
Azerbaijan
Belarus
Moldova
Ukraine
Wyszukiwarka
Podobne podstrony:
tut1 4gui tut1tut1 1tut1 1tut1 4tut1 2tut1 4tut1TUT1tut1 1tut1ED!TUT1tut1 5tut1 2Tut1Tut1tut1 2tut1 3tut1 3więcej podobnych podstron