|
|||||||
New to SitePoint Forums? Register here for free!
|
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Non-Member
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jan 2004
Location: Seattle
Posts: 4,500
|
Need Help with Multi-Table Query Involving Parents
Table gzecoregions (GZER) simply matches animal species with ecoregions. Table gWecoregions (GWER) lists all the ecoregions - AND their parents.
So the following query might display a list of all the ecoregions the wolf is native to: PHP Code:
Alaska Tundra Canadian Taiga Siberian Taiga But I would like to also display the ecoregions' parents (biomes) and the biomes' parents (realms) as well. I discovered that I couldn't do it using just one table, so I created two separate tables for biomes and realms. But I can't figure out how to join them so that I can display something like this: NEARCTIC (realm) TUNDRA (biome) Alaska Tundra BOREAL FOREST (biome) Canadian Taiga PALEARCTIC (realm) BOREAL FOREST (biome) Siberian Taiga It should be easy, but I'm doing something wrong. The following diagrams illustrate the relevant tables and fields... PHP Code:
Gwecoregions also has a field named ERParent, which includes the ID of each region's parent, so everything is listed in a parent-child relationship. Below is a copy of my original query, followed by the query I used to join all four tables. Both queries work, but they produce the same results - a list of ecoregions only. How can I join them so my script also displays the parents? Thanks. PHP Code:
|
|
|
|
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 01:22.









Threaded Mode