title: MySQL PHP - SELECT WHERE id = array()?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1101662/mysql-query-using-an-array">MySQL query using an array</a><br>
    <a href="https://stackoverflow.com/questions/1356008/passing-an-array-to-mysql">Passing an array to mysql</a>  </p>
  </blockquote>
  
  
  
  <p>I have an array in PHP:</p>
  
  <pre><code>$array = array(1, 4, 5, 7);
  </code></pre>
  
  <p>As you can see, I have an array of different values, but I want to write a MYSQL statement that will check if the <code>id</code> is <strong>equal</strong> to any of the values in the array. For example, if a row has an <code>id</code> of 1, it will return that row, the same for 4, 5, and 7. The length of the array can vary due to the nature of the program, so that's where the problem is. Could I just do:</p>
  
  <pre><code>SELECT ...
    FROM ...
   WHERE id = '$array'
  </code></pre>
  
  <p>Or is there a better way?<br>
  If I was unclear, please ask me for more info.</p>