<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="table">
      </a>
      15.2.16 TABLE Statement
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045179562896">
  </a>
  <a class="indexterm" name="idm46045179561824">
  </a>
  <a class="indexterm" name="idm46045179560368">
  </a>
  <p>
   <code class="literal">
    TABLE
   </code>
   is a DML statement which returns rows and
      columns of the named table.
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa74040423"><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-sql"><span class="token keyword">TABLE</span> <span class="token keyword"><em class="replaceable">table_name</em></span> <span class="token punctuation">[</span><span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token keyword"><em class="replaceable">column_name</em></span><span class="token punctuation">]</span> <span class="token punctuation">[</span><span class="token keyword">LIMIT</span> <span class="token keyword"><em class="replaceable">number</em></span> <span class="token punctuation">[</span><span class="token keyword">OFFSET</span> <span class="token keyword"><em class="replaceable">number</em></span><span class="token punctuation">]</span><span class="token punctuation">]</span></code></pre>
  </div>
  <p>
   The
   <code class="literal">
    TABLE
   </code>
   statement in some ways acts like
   <a class="link" href="select.html" title="15.2.13 SELECT Statement">
    <code class="literal">
     SELECT
    </code>
   </a>
   . Given the existence of a
      table named
   <code class="literal">
    t
   </code>
   , the following two statements
      produce identical output:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28115064"><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-sql"><span class="token keyword">TABLE</span> t<span class="token punctuation">;</span>

<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   You can order and limit the number of rows produced by
   <code class="literal">
    TABLE
   </code>
   using
   <code class="literal">
    ORDER BY
   </code>
   and
   <code class="literal">
    LIMIT
   </code>
   clauses, respectively. These function
      identically to the same clauses when used with
   <code class="literal">
    SELECT
   </code>
   (including an optional
   <code class="literal">
    OFFSET
   </code>
   clause with
   <code class="literal">
    LIMIT
   </code>
   ),
      as you can see here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8192908"><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-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">TABLE</span> t<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a  <span class="token punctuation">|</span> b  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>  1 <span class="token punctuation">|</span>  2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>  6 <span class="token punctuation">|</span>  7 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>  9 <span class="token punctuation">|</span>  5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> <span class="token punctuation">-</span>4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 11 <span class="token punctuation">|</span> <span class="token punctuation">-</span>1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 13 <span class="token punctuation">|</span>  3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 14 <span class="token punctuation">|</span>  6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">7 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">TABLE</span> t <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> b<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a  <span class="token punctuation">|</span> b  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> <span class="token punctuation">-</span>4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 11 <span class="token punctuation">|</span> <span class="token punctuation">-</span>1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>  1 <span class="token punctuation">|</span>  2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 13 <span class="token punctuation">|</span>  3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>  9 <span class="token punctuation">|</span>  5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 14 <span class="token punctuation">|</span>  6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>  6 <span class="token punctuation">|</span>  7 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">7 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">TABLE</span> t <span class="token keyword">LIMIT</span> <span class="token number">3</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span> 7 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 9 <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">TABLE</span> t <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> b <span class="token keyword">LIMIT</span> <span class="token number">3</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a  <span class="token punctuation">|</span> b  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> <span class="token punctuation">-</span>4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 11 <span class="token punctuation">|</span> <span class="token punctuation">-</span>1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>  1 <span class="token punctuation">|</span>  2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">TABLE</span> t <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> b <span class="token keyword">LIMIT</span> <span class="token number">3</span> <span class="token keyword">OFFSET</span> <span class="token number">2</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a  <span class="token punctuation">|</span> b  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>  1 <span class="token punctuation">|</span>  2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 13 <span class="token punctuation">|</span>  3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>  9 <span class="token punctuation">|</span>  5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span></code></pre>
  </div>
  <p>
   <code class="literal">
    TABLE
   </code>
   differs from
   <code class="literal">
    SELECT
   </code>
   in
      two key respects:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       TABLE
      </code>
      always displays all columns of the
          table.
     </p>
     <p>
      <span class="emphasis">
       <em>
        Exception
       </em>
      </span>
      : The output of
      <code class="literal">
       TABLE
      </code>
      does
      <span class="emphasis">
       <em>
        not
       </em>
      </span>
      include
          invisible columns. See
      <a class="xref" href="invisible-columns.html" title="15.1.20.10 Invisible Columns">
       Section 15.1.20.10, “Invisible Columns”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       TABLE
      </code>
      does not allow for any arbitrary
          filtering of rows; that is,
      <code class="literal">
       TABLE
      </code>
      does not
          support any
      <code class="literal">
       WHERE
      </code>
      clause.
     </p>
    </li>
   </ul>
  </div>
  <p>
   For limiting which table columns are returned, filtering rows
      beyond what can be accomplished using
   <code class="literal">
    ORDER BY
   </code>
   and
   <code class="literal">
    LIMIT
   </code>
   , or both, use
   <code class="literal">
    SELECT
   </code>
   .
  </p>
  <p>
   <code class="literal">
    TABLE
   </code>
   can be used with temporary tables.
  </p>
  <p>
   <code class="literal">
    TABLE
   </code>
   can also be used in place of
   <code class="literal">
    SELECT
   </code>
   in a number of other constructs,
      including those listed here:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      With set operators such as
      <a class="link" href="union.html" title="15.2.18 UNION Clause">
       <code class="literal">
        UNION
       </code>
      </a>
      , as shown here:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74014246"><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-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">TABLE</span> t1<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span>  3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 7 <span class="token punctuation">|</span>  8 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">TABLE</span> t2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span> 7 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">TABLE</span> t1 <span class="token keyword">UNION</span> <span class="token keyword">TABLE</span> t2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span>  3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 7 <span class="token punctuation">|</span>  8 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span>  2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3 <span class="token punctuation">|</span>  4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span>  7 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">6 rows in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      The
      <a class="link" href="union.html" title="15.2.18 UNION Clause">
       <code class="literal">
        UNION
       </code>
      </a>
      just shown is
          equivalent to the following statement:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90121703"><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-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">UNION</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span>  3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 7 <span class="token punctuation">|</span>  8 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span>  2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3 <span class="token punctuation">|</span>  4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span>  7 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">6 rows in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      <code class="literal">
       TABLE
      </code>
      can also be used together in set
          operations with
      <code class="literal">
       SELECT
      </code>
      statements,
      <a class="link" href="values.html" title="15.2.19 VALUES Statement">
       <code class="literal">
        VALUES
       </code>
      </a>
      statements, or both. See
      <a class="xref" href="union.html" title="15.2.18 UNION Clause">
       Section 15.2.18, “UNION Clause”
      </a>
      ,
      <a class="xref" href="except.html" title="15.2.4 EXCEPT Clause">
       Section 15.2.4, “EXCEPT Clause”
      </a>
      , and
      <a class="xref" href="intersect.html" title="15.2.8 INTERSECT Clause">
       Section 15.2.8, “INTERSECT Clause”
      </a>
      , for more information and
          examples. See also
      <a class="xref" href="set-operations.html" title="15.2.14 Set Operations with UNION, INTERSECT, and EXCEPT">
       Section 15.2.14, “Set Operations with UNION, INTERSECT, and EXCEPT”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      With
      <code class="literal">
       INTO
      </code>
      to populate user variables, and
          with
      <code class="literal">
       INTO OUTFILE
      </code>
      or
      <code class="literal">
       INTO
          DUMPFILE
      </code>
      to write table data to a file. See
      <a class="xref" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
       Section 15.2.13.1, “SELECT ... INTO Statement”
      </a>
      , for more specific information
          and examples.
     </p>
    </li>
    <li class="listitem">
     <p>
      In many cases where you can employ subqueries. Given any table
      <code class="literal">
       t1
      </code>
      with a column named
      <code class="literal">
       a
      </code>
      , and a second table
      <code class="literal">
       t2
      </code>
      having a single column, statements such as the following are
          possible:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa54037426"><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-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> a <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">TABLE</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      Assuming that the single column of table
      <code class="literal">
       t1
      </code>
      is named
      <code class="literal">
       x
      </code>
      , the preceding is equivalent to
          each of the statements shown here (and produces exactly the
          same result in either case):
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa75553223"><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-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> a <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> x <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> a <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      See
      <a class="xref" href="subqueries.html" title="15.2.15 Subqueries">
       Section 15.2.15, “Subqueries”
      </a>
      , for more information.
     </p>
    </li>
    <li class="listitem">
     <p>
      With
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      and
      <a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
       <code class="literal">
        REPLACE
       </code>
      </a>
      statements, where you
          would otherwise use
      <a class="link" href="select.html" title="15.2.13 SELECT Statement">
       <code class="literal">
        SELECT *
       </code>
      </a>
      .
          See
      <a class="xref" href="insert-select.html" title="15.2.7.1 INSERT ... SELECT Statement">
       Section 15.2.7.1, “INSERT ... SELECT Statement”
      </a>
      , for more information and
          examples.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="table.html" title="15.2.16 TABLE Statement">
       <code class="literal">
        TABLE
       </code>
      </a>
      can also be used in many
          cases in place of the
      <a class="link" href="select.html" title="15.2.13 SELECT Statement">
       <code class="literal">
        SELECT
       </code>
      </a>
      in
      <a class="link" href="create-table-select.html" title="15.1.20.4 CREATE TABLE ... SELECT Statement">
       <code class="literal">
        CREATE
          TABLE ... SELECT
       </code>
      </a>
      or
      <a class="link" href="create-view.html" title="15.1.23 CREATE VIEW Statement">
       <code class="literal">
        CREATE VIEW ...
          SELECT
       </code>
      </a>
      . See the descriptions of these statements for
          more information and examples.
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
