<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="no-matching-rows">
      </a>
      B.3.4.7 Solving Problems with No Matching Rows
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045053473744">
  </a>
  <a class="indexterm" name="idm46045053472704">
  </a>
  <p>
   If you have a complicated query that uses many tables but that
          returns no rows, you should use the following procedure to
          find out what is wrong:
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Test the query with
      <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
       <code class="literal">
        EXPLAIN
       </code>
      </a>
      to check whether you can find something that is obviously
              wrong. See
      <a class="xref" href="explain.html" title="15.8.2 EXPLAIN Statement">
       Section 15.8.2, “EXPLAIN Statement”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Select only those columns that are used in the
      <code class="literal">
       WHERE
      </code>
      clause.
     </p>
    </li>
    <li class="listitem">
     <p>
      Remove one table at a time from the query until it returns
              some rows. If the tables are large, it is a good idea to
              use
      <code class="literal">
       LIMIT 10
      </code>
      with the query.
     </p>
    </li>
    <li class="listitem">
     <p>
      Issue a
      <a class="link" href="select.html" title="15.2.13 SELECT Statement">
       <code class="literal">
        SELECT
       </code>
      </a>
      for the
              column that should have matched a row against the table
              that was last removed from the query.
     </p>
    </li>
    <li class="listitem">
     <p>
      If you are comparing
      <a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
       <code class="literal">
        FLOAT
       </code>
      </a>
      or
      <a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
       <code class="literal">
        DOUBLE
       </code>
      </a>
      columns with
              numbers that have decimals, you cannot use equality
              (
      <code class="literal">
       =
      </code>
      ) comparisons. This problem is common
              in most computer languages because not all floating-point
              values can be stored with exact precision. In some cases,
              changing the
      <a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
       <code class="literal">
        FLOAT
       </code>
      </a>
      to a
      <a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
       <code class="literal">
        DOUBLE
       </code>
      </a>
      fixes this. See
      <a class="xref" href="problems-with-float.html" title="B.3.4.8 Problems with Floating-Point Values">
       Section B.3.4.8, “Problems with Floating-Point Values”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If you still cannot figure out what is wrong, create a
              minimal test that can be run with
      <code class="literal">
       mysql test &lt;
              query.sql
      </code>
      that shows your problems. You can
              create a test file by dumping the tables with
      <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
       <span class="command">
        <strong>
         mysqldump --quick db_name
         <em class="replaceable">
          <code>
           tbl_name_1
          </code>
         </em>
         ...
         <em class="replaceable">
          <code>
           tbl_name_n
          </code>
         </em>
         &gt;
              query.sql
        </strong>
       </span>
      </a>
      . Open the file in an editor, remove
              some insert lines (if there are more than needed to
              demonstrate the problem), and add your
      <a class="link" href="select.html" title="15.2.13 SELECT Statement">
       <code class="literal">
        SELECT
       </code>
      </a>
      statement at the end
              of the file.
     </p>
     <p>
      Verify that the test file demonstrates the problem by
              executing these commands:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa23333681"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">mysqladmin</span> create test2
<span class="token prompt">$&gt; </span><span class="token command">mysql</span> test2 &lt; query<span class="token punctuation">.</span>sql</code></pre>
     </div>
     <p>
      Attach the test file to a bug report, which you can file
              using the instructions in
      <a class="xref" href="bug-reports.html" title="1.6 How to Report Bugs or Problems">
       Section 1.6, “How to Report Bugs or Problems”
      </a>
      .
     </p>
    </li>
   </ol>
  </div>
 </div>
 <br/>
</div>
