|
BBC Country Profiles
Some examples of simple WHERE statements:
|
| name |
region |
area |
population |
gdp |
| Afghanistan |
South Asia |
652225 |
26000000 |
|
| Albania |
Europe |
28728 |
3200000 |
6656000000 |
| Algeria |
Middle East |
2400000 |
32900000 |
75012000000 |
| Andorra |
Europe |
468 |
64000 |
|
| ... |
|
1. The example shows the population of 'France'.
Strings should be in 'single quotes';
Show the population of Germany
|
Results
|
2.
This query shows the population density population/area
for each country where the area is over 5,000,000 km2.
Show the per capita gdp: gdp/population
for each country where the area is over 5,000,000 km2
|
Results
|
3. Where to find some very small, very rich countries.
We use AND to ensure that two or more conditions hold
true.
The example shows the countries where the population is small and the
gdp is high.
Show the name and region where the area is less then 2000 and the gdp is more than 5000000000
|
Results
|
4. Checking a list
The word IN allows us to check if an item is in a list.
The example shows the name and population for the countries 'Ireland',
'Iceland' and 'Denmark'
Show the name and the population for 'Denmark', 'Finland', 'Norway', 'Sweden'
|
Results
|
5. What are the countries beginning with G?
The word LIKE permits pattern matching - % is the
wildcard.
The examples shows countries beginning with D
Show each country that begins with G
|
Results
|
6. Which countries are not too small and not too big?
BETWEEN allows range checking - note that it is
inclusive.
Show the area in 1000 square km. Show area/1000
instead of area
|
Results
|
| |