Note that there are some explanatory texts on larger screens.

plurals
  1. POmysqli returns 1 row instead of 2
    primarykey
    data
    text
    <p>I have this query:</p> <pre><code>SELECT `ca`.*, `a`.* FROM `container_asset` AS `ca` LEFT JOIN `asset` AS `a` ON ca.asset_id = a.id WHERE `container_id` = '4' AND `deleted` = '0' AND `reason` IN ('main', 'previous_version') ORDER BY `reason` ASC, `asset_id` DESC </code></pre> <p>and I am expecting to returns two rows, but when I execute the query with this command:</p> <pre><code>$conn =new \mysqli('localhost', 'root', '12345', 'assetdb') or die("Error " . mysqli_error($link)); $res3 = $conn-&gt;query("SELECT `ca`.*, `a`.* FROM `container_asset` AS `ca` LEFT JOIN `asset` AS `a` ON ca.asset_id = a.id WHERE `container_id` = '4' AND `deleted` = '0' AND `reason` IN ('main', 'previous_version') ORDER BY `reason` ASC, `asset_id` DESC"); while ($r = mysqli_fetch_array($res3)) { echo $r['id']."\n"; } </code></pre> <p>it returns 1 row while fetching results But when I execute the query directly (in heidisql or phpmyadmin) it returns the expected results, 2 rows.</p> <p>I cannot explaing this problem?</p> <p><strong>EDIT</strong></p> <p>I make some more test, if I am expecting 5 rows it returns 4, so it returns 1 row less.</p> <p><strong>EDIT2</strong></p> <p>data: container_asset table, asset_id foreing key in asset->id:</p> <pre> "container_id" "asset_id" "reason" "1" "2" "main" "2" "1" "main" "3" "3" "main" "4" "3" "previous_version" "4" "4" "main" </pre> <p>asset table</p> <pre> "id" "asset_class" "deleted" "file_name" "1" "video" "0" "ÄÖ.jpg" "2" "image" "0" "èungrandeguitar.jpg" "3" "image" "0" "3.jpg" "4" "image" "0" "çàù.jpg" </pre> <p><strong>EDIT 3</strong></p> <p>Even if I remove the join the result is still wrong:</p> <pre><code>SELECT `ca`.* FROM `container_asset` AS `ca` WHERE ca.`container_id` = '4' AND `reason` IN ('main', 'previous_version') ORDER BY `reason` ASC, `asset_id` DESC </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload