This would seem to be an extremely simple query... However, the results I'm getting disagree and its driving me mad trying to figure out! Let's see if you can deduce the problem...
Originally this was part of a much larger query, when it became clear that equijoining monster_habitat = habitat_ID was failing (only where habitat_ID was 9), I reduced the size of the query and began asking for the IDs that I was using to join on.
At that point I saw that it was joining a monster_habitat of mn (1-9) to habitat_ID of hn+1 (2-9). If mn was 9, no habitat_ID would be matched and the larger query failed.
Here's a screen of the first query's results...
Clearly, Kyogre's habitat_ID is 7 and yet its being joined to the habitat_ID of 8... Why in the hell is it doing this?
As frustrating as this is, it ups the ante when the following continues to work...
Initially the different script gets a value from the URI, let's say "urban" The name and ID are queried for, which returns Urban and 8. Later, I run a larger query, again reduced for this thread, which uses the ID query A got, again being 8.
So the query, call it B, getting data relevant to monsters with that ID, 8, is done...
And the result...
...yea...
Code:
SELECT h.habitat_ID, h.habitat_name, m.monster_name, m.monster_habitat
FROM pkmn_habitat h, pkmn_monster m
WHERE h.habitat_ID = '8'
AND m.monster_habitat = h.habitat_ID
At that point I saw that it was joining a monster_habitat of mn (1-9) to habitat_ID of hn+1 (2-9). If mn was 9, no habitat_ID would be matched and the larger query failed.
Here's a screen of the first query's results...
Clearly, Kyogre's habitat_ID is 7 and yet its being joined to the habitat_ID of 8... Why in the hell is it doing this?
As frustrating as this is, it ups the ante when the following continues to work...
Initially the different script gets a value from the URI, let's say "urban" The name and ID are queried for, which returns Urban and 8. Later, I run a larger query, again reduced for this thread, which uses the ID query A got, again being 8.
So the query, call it B, getting data relevant to monsters with that ID, 8, is done...
Code:
SELECT monster_name, monster_habitat
FROM pkmn_monster
WHERE monster_habitat = '8'
...yea...