![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a table 'major' containing only two columns 'city' and 'pop'. I have another table 'country' containing 100 columns. |
|
I want to SELECT from COUNTRY those rows where the city's pop is more than 10000. SELECT ind,fish,city FROM country WHERE country.city=major.city AND major.city.pop<10000 |
|
I appreciate I cannot say "major.city.pop" but how do I access 'pop' of 'city' in 'major'? |
#3
| |||
| |||
|
|
Am 13.02.2011 09:58, schrieb John: I have a table 'major' containing only two columns 'city' and 'pop'. I have another table 'country' containing 100 columns. Which seems to be a broken design to me... Tables with that many columns almost always indicate some mistakes in the design. I want to SELECT from COUNTRY those rows where the city's pop is more than 10000. SELECT ind,fish,city FROM country WHERE country.city=major.city AND major.city.pop<10000 Which confirms my suspicion about the broken design: A city is not an attribute of a country, it's the other way round. Except, the city means the capital here... I appreciate I cannot say "major.city.pop" but how do I access 'pop' of 'city' in 'major'? Why 'pop' of 'city'? You said, your table is 'major', containing only two columns 'city' and 'pop'. So you access the column 'pop' of 'major': major.pop HTH, Helmut |
#4
| |||
| |||
|
|
"Helmut Chang" <usenet (AT) helmutchang (DOT) at> wrote in message news:4d57b45c$0$18682$91cee783 (AT) newsreader03 (DOT) highway.telekom.at... Am 13.02.2011 09:58, schrieb John: I have a table 'major' containing only two columns 'city' and 'pop'. I have another table 'country' containing 100 columns. Which seems to be a broken design to me... Tables with that many columns almost always indicate some mistakes in the design. I want to SELECT from COUNTRY those rows where the city's pop is more than 10000. SELECT ind,fish,city FROM country WHERE country.city=major.city AND major.city.pop<10000 |
|
Which confirms my suspicion about the broken design: A city is not an attribute of a country, it's the other way round. Except, the city means the capital here... I appreciate I cannot say "major.city.pop" but how do I access 'pop' of 'city' in 'major'? Why 'pop' of 'city'? You said, your table is 'major', containing only two columns 'city' and 'pop'. So you access the column 'pop' of 'major': major.pop My question is how to correct the WHERE statement so that I only extract those rows where the country.city and the major.city are the same but the major.pop is less than 10000. |
#5
| |||
| |||
|
|
Hi I have a table 'major' containing only two columns 'city' and 'pop'. I have another table 'country' containing 100 columns. I want to SELECT from COUNTRY those rows where the city's pop is more than 10000. SELECT ind,fish,city FROM country WHERE country.city=major.city AND major.city.pop<10000 I appreciate I cannot say "major.city.pop" but how do I access 'pop' of 'city' in 'major'? Regards John |
#6
| |||
| |||
|
|
What is to stop 2 countries having cities with the same name? |
#7
| |||
| |||
|
|
Captain Paralytic wrote on 13.02.2011 13:33: What is to stop 2 countries having cities with the same name? That is not something that should be prevented. It's not really uncommon, just think about the many U.S. cities that were named after european cities (Berlin, Paris, London, Madrid) |
|
Regards Thomas |
#8
| |||
| |||
|
|
Captain Paralytic wrote on 13.02.2011 13:33: What is to stop 2 countries having cities with the same name? That is not something that should be prevented. It's not really uncommon, just think about the many U.S. cities that werenamed after european cities (Berlin, Paris, London, Madrid) Regards Thomas |
#9
| |||
| |||
|
|
On Feb 13, 12:51*pm, Hans Castorp <SOZRBLNTL... (AT) spammotel (DOT) com> wrote: Captain Paralytic wrote on 13.02.2011 13:33: What is to stop 2 countries having cities with the same name? It's not really uncommon, just think about the many U.S. cities that were named after european cities (Berlin, Paris, London, Madrid) That is my point. The schema as described cannot handle this situation. |
#10
| |||
| |||
|
|
Try and get the village of Baarle into a DB-schema! :-) http://en.wikipedia.org/wiki/Baarle-Hertog |
![]() |
| Thread Tools | |
| Display Modes | |
| |