title: Unexpected behavior of UNION ALL operator
body: <p>I have the following MySql tables.</p>
  
  <p>Table <code>tblUsg</code> defined as such:</p>
  
  <pre><code>CREATE TABLE `tblUsg` (
  `id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `ip` VARCHAR(46) NOT NULL,
  `dtm` DATETIME NOT NULL,
  `huid` BINARY(32) NOT NULL,
  `licnm` VARCHAR(20) NOT NULL,
  `lichld` VARCHAR(256) NOT NULL,
  `flgs` INT NOT NULL,
  `agnt` VARCHAR(256),
  
  INDEX `ix_huid` (`huid`),
  INDEX `ix_licnm` (`licnm`),
  UNIQUE KEY `ix_lichuid` (`huid`, `licnm`)
  ) AUTO_INCREMENT=0 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
  </code></pre>
  
  <p>And table <code>tblLics</code> defined as such:</p>
  
  <pre><code>CREATE TABLE `wosLics` (
  `id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `licnm` VARCHAR(20) NOT NULL,
  `desc` VARCHAR(256) NOT NULL,
  `maxcpy` INT NOT NULL,
  `dtmFrom` DATETIME,
  `dtmTo` DATETIME,
  `stat` INT NOT NULL,
  
  UNIQUE KEY `ix_licnm` (`licnm`)
  ) AUTO_INCREMENT=0 CHARACTER SET utf8 COLLATE utf8_unicode_ci;
  </code></pre>
  
  <p>I then call the following PHP script when, say, both tables are empty:</p>
  
  <pre><code>$link = @mysql_connect($HOSTNAME, $USERNAME, $PASSWD);
  @mysql_select_db($DBNAME);
  mysql_set_charset('utf8', $link);
  
  $res = @mysql_query(
      "SELECT `maxcpy`, `stat`, `dtmFrom`, `dtmTo` FROM `tblLics` WHERE `licnm`='zbcdefghijklmnopqrsu'\n".
      "UNION ALL\n".
      "SELECT COUNT(*), NULL, NULL, NULL FROM `tblUsg` WHERE `licnm`='zbcdefghijklmnopqrsu'\n".
      "UNION ALL\n".
      "SELECT COUNT(*), NULL, NULL, NULL FROM `tblUsg` WHERE (`licnm`='zbcdefghijklmnopqrsu' AND `huid`='a871c47a7f48a12b38a994e48a9659fab5d6376f3dbce37559bcb617efe8662d')"
      , $link);
  if($res)
  {
      $row0 = @mysql_fetch_row($res);
      $row1 = @mysql_fetch_row($res);
      $row2 = @mysql_fetch_row($res);
  
      echo("&lt;br/&gt;0::&lt;br/&gt;");
      var_dump($row0);
      echo("&lt;br/&gt;1::&lt;br/&gt;");
      var_dump($row1);
      echo("&lt;br/&gt;2::&lt;br/&gt;");
      var_dump($row2);
  }
  </code></pre>
  
  <p>Which outputs this:</p>
  
  <pre><code>0::
  array(4) { [0]=&gt; string(1) "0" [1]=&gt; NULL [2]=&gt; NULL [3]=&gt; NULL } 
  1::
  array(4) { [0]=&gt; string(1) "0" [1]=&gt; NULL [2]=&gt; NULL [3]=&gt; NULL } 
  2::
  bool(false)
  </code></pre>
  
  <p>My question is why my <code>$row2</code> is <code>false</code> when <code>$row1</code> is the array as I would've expected?</p>