My MySQL query returns different results depending on how the query is submitted. When the query is submitted through the MySQL Console results in.
mysql> SELECT `modx`.coverage_nation.id,
-> `modx`.coverage_nation.name,
-> `modx`.coverage_national_region.id,
-> `modx`.coverage_national_region.name
-> FROM `modx`.coverage_nation_part
-> RIGHT JOIN `modx`.coverage_national_region ON (`modx`.coverage_nati
on_part.nation_regionID = `modx`.coverage_national_region.id)
-> RIGHT JOIN `modx`.coverage_nation ON (`modx`.coverage_nation_part.n
ationID = `modx`.coverage_nation.id)
-> ORDER BY `modx`.coverage_nation.name ASC, `modx`.coverage_national_region
.name ASC;
+----+---------------+------+------+
| id | name | id | name |
+----+---------------+------+------+
| 3 | Canada | NULL | NULL |
| 18 | Chad | NULL | NULL |
| 17 | Germany | NULL | NULL |
| 15 | Italy | NULL | NULL |
| 2 | Mexico | NULL | NULL |
| 19 | Nigeria | NULL | NULL |
| 14 | Russia | NULL | NULL |
| 16 | Spain | NULL | NULL |
| 1 | United States | NULL | NULL |
+----+---------------+------+------+
9 rows in set (0.00 sec)
When the same query is submitted using PHP's mysql_query
it returns only one row.
$query .= "SELECT `modx`.coverage_nation.id,
`modx`.coverage_nation.name,
`modx`.coverage_national_region.id,
`modx`.coverage_national_region.name
FROM `modx`.coverage_nation_part
RIGHT JOIN `modx`.coverage_national_region ON (`modx`.coverage_nation_part.nation_regionID = `modx`.coverage_national_region.id)
RIGHT JOIN `modx`.coverage_nation ON (`modx`.coverage_nation_part.nationID = `modx`.coverage_nation.id)
ORDER BY `modx`.coverage_nation.name ASC, `modx`.coverage_national_region.name ASC;";
$resultSet = mysql_query($query) or die("query failed ".mysql_error());
while($row = mysql_fetch_array($resultSet,MYSQL_NUM)) {
// handle each result here
}
Returns only Canada. Does anyone have any ideas as to how I might solve this?