title: Check whether a field has the property `UNIQUE` in mysql and PHP
body: <p>How can I check whether a field from a table is set as <strong>UNIQUE</strong>?</p>
  
  <p>For example I have a table named <code>users</code> with a field <code>email</code> set as <code>UNIQUE</code> and a field <code>picture</code> not set as <code>UNIQUE</code>, I want before selecting check whether the field is set set as <code>UNIQUE</code> if not then don't do the <code>SELECT</code>.</p>
  
  <p>I tried to <code>SELECT</code> then count the returned number of row, if more than 1 then it's not <code>UNIQUE</code>, </p>
  
  <pre><code>"SELECT * FROM table WHERE email='$email'"
  //...some mysql php line later
  if($count &gt; 1){
      //return nothing
  }
  </code></pre>
  
  <p>but it's not efficient, what if there is no duplicate.</p>
  
  <p>What's the best way to check whether a field is set as <code>UNIQUE</code> in <code>PHP</code>?</p>
  
  <p>Edit: no duplicate doesn't mean it has <code>UNIQUE</code> property</p>