<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="set">
      </a>
      13.3.6 The SET Type
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045212348352">
  </a>
  <a class="indexterm" name="idm46045212347280">
  </a>
  <p>
   A
   <code class="literal">
    SET
   </code>
   is a string object that can have zero
        or more values, each of which must be chosen from a list of
        permitted values specified when the table is created.
   <code class="literal">
    SET
   </code>
   column values that consist of multiple
        set members are specified with members separated by commas
        (
   <code class="literal">
    ,
   </code>
   ). A consequence of this is that
   <code class="literal">
    SET
   </code>
   member values should not themselves
        contain commas.
  </p>
  <p>
   For example, a column specified as
   <code class="literal">
    SET('one', 'two')
        NOT NULL
   </code>
   can have any of these values:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa11968727"><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-simple">''
'one'
'two'
'one<span class="token punctuation">,</span>two'</code></pre>
  </div>
  <p>
   A
   <a class="link" href="set.html" title="13.3.6 The SET Type">
    <code class="literal">
     SET
    </code>
   </a>
   column can have a maximum
        of 64 distinct members.
  </p>
  <p>
   Duplicate values in the definition cause a warning, or an error
        if strict SQL mode is enabled.
  </p>
  <a class="indexterm" name="idm46045212338000">
  </a>
  <p>
   Trailing spaces are automatically deleted from
   <code class="literal">
    SET
   </code>
   member values in the table definition
        when a table is created.
  </p>
  <p>
   See
   <a class="xref" href="storage-requirements.html#data-types-storage-reqs-strings" title="String Type Storage Requirements">
    String Type Storage Requirements
   </a>
   for
        storage requirements for the
   <a class="link" href="set.html" title="13.3.6 The SET Type">
    <code class="literal">
     SET
    </code>
   </a>
   type.
  </p>
  <p>
   See
   <a class="xref" href="string-type-syntax.html" title="13.3.1 String Data Type Syntax">
    Section 13.3.1, “String Data Type Syntax”
   </a>
   for
   <a class="link" href="set.html" title="13.3.6 The SET Type">
    <code class="literal">
     SET
    </code>
   </a>
   type syntax and length
        limits.
  </p>
  <p>
   When retrieved, values stored in a
   <code class="literal">
    SET
   </code>
   column
        are displayed using the lettercase that was used in the column
        definition. Note that
   <code class="literal">
    SET
   </code>
   columns can be
        assigned a character set and collation. For binary or
        case-sensitive collations, lettercase is taken into account when
        assigning values to the column.
  </p>
  <p>
   MySQL stores
   <code class="literal">
    SET
   </code>
   values numerically, with the
        low-order bit of the stored value corresponding to the first set
        member. If you retrieve a
   <code class="literal">
    SET
   </code>
   value in a
        numeric context, the value retrieved has bits set corresponding
        to the set members that make up the column value. For example,
        you can retrieve numeric values from a
   <code class="literal">
    SET
   </code>
   column like this:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa85681309"><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> <em class="replaceable">set_col</em><span class="token operator">+</span><span class="token number">0</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   If a number is stored into a
   <code class="literal">
    SET
   </code>
   column, the
        bits that are set in the binary representation of the number
        determine the set members in the column value. For a column
        specified as
   <code class="literal">
    SET('a','b','c','d')
   </code>
   , the
        members have the following decimal and binary values.
  </p>
  <div class="informaltable">
   <table summary="Decimal and binary values for members of a column specified as SET('a','b','c','d').">
    <colgroup>
     <col style="width: 15%"/>
     <col style="width: 20%"/>
     <col style="width: 20%"/>
    </colgroup>
    <thead>
     <tr>
      <th scope="col">
       <code class="literal">
        SET
       </code>
       Member
      </th>
      <th scope="col">
       Decimal Value
      </th>
      <th scope="col">
       Binary Value
      </th>
     </tr>
    </thead>
    <tbody>
     <tr>
      <th scope="row">
       <code class="literal">
        'a'
       </code>
      </th>
      <td>
       <code class="literal">
        1
       </code>
      </td>
      <td>
       <code class="literal">
        0001
       </code>
      </td>
     </tr>
     <tr>
      <th scope="row">
       <code class="literal">
        'b'
       </code>
      </th>
      <td>
       <code class="literal">
        2
       </code>
      </td>
      <td>
       <code class="literal">
        0010
       </code>
      </td>
     </tr>
     <tr>
      <th scope="row">
       <code class="literal">
        'c'
       </code>
      </th>
      <td>
       <code class="literal">
        4
       </code>
      </td>
      <td>
       <code class="literal">
        0100
       </code>
      </td>
     </tr>
     <tr>
      <th scope="row">
       <code class="literal">
        'd'
       </code>
      </th>
      <td>
       <code class="literal">
        8
       </code>
      </td>
      <td>
       <code class="literal">
        1000
       </code>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
  <p>
   If you assign a value of
   <code class="literal">
    9
   </code>
   to this column,
        that is
   <code class="literal">
    1001
   </code>
   in binary, so the first and
        fourth
   <code class="literal">
    SET
   </code>
   value members
   <code class="literal">
    'a'
   </code>
   and
   <code class="literal">
    'd'
   </code>
   are selected
        and the resulting value is
   <code class="literal">
    'a,d'
   </code>
   .
  </p>
  <p>
   For a value containing more than one
   <code class="literal">
    SET
   </code>
   element, it does not matter what order the elements are listed
        in when you insert the value. It also does not matter how many
        times a given element is listed in the value. When the value is
        retrieved later, each element in the value appears once, with
        elements listed according to the order in which they were
        specified at table creation time. Suppose that a column is
        specified as
   <code class="literal">
    SET('a','b','c','d')
   </code>
   :
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa30812259"><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">CREATE</span> <span class="token keyword">TABLE</span> myset <span class="token punctuation">(</span>col <span class="token datatype">SET</span><span class="token punctuation">(</span><span class="token string">'a'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">,</span> <span class="token string">'c'</span><span class="token punctuation">,</span> <span class="token string">'d'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   If you insert the values
   <code class="literal">
    'a,d'
   </code>
   ,
   <code class="literal">
    'd,a'
   </code>
   ,
   <code class="literal">
    'a,d,d'
   </code>
   ,
   <code class="literal">
    'a,d,a'
   </code>
   , and
   <code class="literal">
    'd,a,d'
   </code>
   :
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28884946"><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">INSERT</span> <span class="token keyword">INTO</span> myset <span class="token punctuation">(</span>col<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> 
<span class="token prompt">-&gt;</span> <span class="token punctuation">(</span><span class="token string">'a,d'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token string">'d,a'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token string">'a,d,a'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token string">'a,d,d'</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token string">'d,a,d'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 5 rows affected (0.01 sec)</span>
<span class="token output">Records: 5  Duplicates: 0  Warnings: 0</span></code></pre>
  </div>
  <p>
   Then all these values appear as
   <code class="literal">
    'a,d'
   </code>
   when
        retrieved:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa94163394"><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> col <span class="token keyword">FROM</span> myset<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>
<span class="token output"><span class="token punctuation">|</span> col  <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>
<span class="token output"><span class="token punctuation">|</span> a,d  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> a,d  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> a,d  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> a,d  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> a,d  <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>
<span class="token output">5 rows in set (0.04 sec)</span></code></pre>
  </div>
  <p>
   If you set a
   <code class="literal">
    SET
   </code>
   column to an unsupported
        value, the value is ignored and a warning is issued:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa60982313"><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">INSERT</span> <span class="token keyword">INTO</span> myset <span class="token punctuation">(</span>col<span class="token punctuation">)</span> <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token string">'a,d,d,s'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected, 1 warning (0.03 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</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 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 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 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 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 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> Level   <span class="token punctuation">|</span> Code <span class="token punctuation">|</span> Message                                  <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 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 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 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 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 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> Warning <span class="token punctuation">|</span> 1265 <span class="token punctuation">|</span> Data truncated for column 'col' at row 1 <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 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 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 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 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 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">1 row in set (0.04 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> col <span class="token keyword">FROM</span> myset<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>
<span class="token output"><span class="token punctuation">|</span> col  <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>
<span class="token output"><span class="token punctuation">|</span> a,d  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> a,d  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> a,d  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> a,d  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> a,d  <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> a,d  <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>
<span class="token output">6 rows in set (0.01 sec)</span></code></pre>
  </div>
  <p>
   If strict SQL mode is enabled, attempts to insert invalid
   <code class="literal">
    SET
   </code>
   values result in an error.
  </p>
  <p>
   <code class="literal">
    SET
   </code>
   values are sorted numerically.
   <code class="literal">
    NULL
   </code>
   values sort before
        non-
   <code class="literal">
    NULL
   </code>
   <code class="literal">
    SET
   </code>
   values.
  </p>
  <p>
   Functions such as
   <a class="link" href="aggregate-functions.html#function_sum">
    <code class="literal">
     SUM()
    </code>
   </a>
   or
   <a class="link" href="aggregate-functions.html#function_avg">
    <code class="literal">
     AVG()
    </code>
   </a>
   that expect a numeric
        argument cast the argument to a number if necessary. For
   <code class="literal">
    SET
   </code>
   values, the cast operation causes the
        numeric value to be used.
  </p>
  <p>
   Normally, you search for
   <code class="literal">
    SET
   </code>
   values using the
   <a class="link" href="string-functions.html#function_find-in-set">
    <code class="literal">
     FIND_IN_SET()
    </code>
   </a>
   function or the
   <a class="link" href="string-comparison-functions.html#operator_like">
    <code class="literal">
     LIKE
    </code>
   </a>
   operator:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa15922860"><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> <em class="replaceable">tbl_name</em> <span class="token keyword">WHERE</span> <span class="token function">FIND_IN_SET</span><span class="token punctuation">(</span><span class="token string">'<em class="replaceable">value</em>'</span><span class="token punctuation">,</span><em class="replaceable">set_col</em><span class="token punctuation">)</span><span class="token operator">&gt;</span><span class="token number">0</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em> <span class="token keyword">WHERE</span> <em class="replaceable">set_col</em> <span class="token operator">LIKE</span> <span class="token string">'%<em class="replaceable">value</em>%'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   The first statement finds rows where
   <em class="replaceable">
    <code>
     set_col
    </code>
   </em>
   contains the
   <em class="replaceable">
    <code>
     value
    </code>
   </em>
   set member. The second is
        similar, but not the same: It finds rows where
   <em class="replaceable">
    <code>
     set_col
    </code>
   </em>
   contains
   <em class="replaceable">
    <code>
     value
    </code>
   </em>
   anywhere, even as a substring
        of another set member.
  </p>
  <p>
   The following statements also are permitted:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa66189434"><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> <em class="replaceable">tbl_name</em> <span class="token keyword">WHERE</span> <em class="replaceable">set_col</em> <span class="token operator">&amp;</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em> <span class="token keyword">WHERE</span> <em class="replaceable">set_col</em> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">val1</em>,<em class="replaceable">val2</em>'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   The first of these statements looks for values containing the
        first set member. The second looks for an exact match. Be
        careful with comparisons of the second type. Comparing set
        values to
   <code class="literal">
    '
    <em class="replaceable">
     <code>
      val1
     </code>
    </em>
    ,
    <em class="replaceable">
     <code>
      val2
     </code>
    </em>
    '
   </code>
   returns different results than comparing values to
   <code class="literal">
    '
    <em class="replaceable">
     <code>
      val2
     </code>
    </em>
    ,
    <em class="replaceable">
     <code>
      val1
     </code>
    </em>
    '
   </code>
   .
        You should specify the values in the same order they are listed
        in the column definition.
  </p>
  <p>
   To determine all possible values for a
   <code class="literal">
    SET
   </code>
   column, use
   <code class="literal">
    SHOW COLUMNS FROM
    <em class="replaceable">
     <code>
      tbl_name
     </code>
    </em>
    LIKE
    <em class="replaceable">
     <code>
      set_col
     </code>
    </em>
   </code>
   and parse the
   <code class="literal">
    SET
   </code>
   definition in the
   <code class="literal">
    Type
   </code>
   column of the output.
  </p>
  <p>
   In the C API,
   <code class="literal">
    SET
   </code>
   values are returned as
        strings. For information about using result set metadata to
        distinguish them from other strings, see
   <a class="ulink" href="/doc/c-api/8.4/en/c-api-data-structures.html" target="_top">
    C API Basic Data Structures
   </a>
   .
  </p>
 </div>
 <br/>
</div>
