Query result in MySQL Console does not match the result of PHP's mysql_query()
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
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?
This question and answers originated from www.stackoverflow.com
Question by Brook Julias (9/20/2010 5:09:19 PM)
Answer |
There was an error in my code somewhere. I sat down and rewrote it and it now works.
Answer by Brook Julias
Find More Answers