Query result in MySQL Console does not match the result of PHP's mysql_query()

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 (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

Find More Answers
Related Topics  php  mysql
Related Questions
  • Change the result of mysql_query

    Can I modify the result that I have received from mysql_query than reset the pointer with mysql_data_seek($result, 0) and process the output like from normal query Dummy example: $result = mys…
  • MySQL query result split

    This is somewhat of a multipart question, but.. I am looking to query a MySQL table to get fields from a event category table. Each category has a specific calendar assigned to it, in the "cal…
  • cache mysql query result?

    I use a several mysql queries on a page to fetch data from multiple tables using mysqli prepare statements. Lets say i have like 20 queries from database tables on a page. Since there are so many…
  • Printing result of mysql query from variable

    So I wrote this earlier (in php), but everytime I try echo $test", I just get back resource id 5. Does anyone know how to actually print out the mysql query from the variable? $dave= mysql_query(…
  • PHP/MySQL verifying the result of a query?

    I've got this code that should delete a row, containing a certain number from the database. if ( isset($_POST['textfield_numtodelete']) ) { $numToDel = $_POST['textfield_numtodelete']; $resdel …
  • How to echo the result of my query? PHP & MySQL

    so I have this query: SELECT COUNT( * ) AS cnt FROM table WHERE datetime > NOW( ) - INTERVAL 45 SECOND When I preform this query in MySQL I get the result: cnt 25 (http://puu.sh/7ZNh.png) …
  • Display MYSQL query result in horizontal view

    We have employee attendance system in mysql database but it dont have the reporting capability, i am trying to generate reports using PHP. Let me explain clearly : employee punch in and punch …
  • mysql query result in php variable

    Is there any way to store mysql result in php variable? thanks $query = "SELECT username,userid FROM user WHERE username = 'admin' "; $result=$conn->query($query); then I want to print sel…
  • looping MySQL query result in PHP

    $b = 1; $d = mysql_query("select *from 'table_name'"); while($b < 10){ while($e = mysql_fetch_array($d)){ echo $e['name_field']; } $b++; } I want to loop the output, but I'm stuck. …
  • Inserting the result of mysql_query() into the same database

    Still learning PHP. I just hit a brick and need some quick help. Never handled this before. I have the php code below: I just need to automate a process. My intention is to select data from a holdin…