title: How to typecast for mysql in()
body: <p>I'm building a php script that creates a query string like,</p>
  
  <pre><code>$products = array(873, 874, 875);
  $sql = 'select * from product_thumbnails where product in (' . implode($products, ', ') . ')';
  </code></pre>
  
  <p>which creates a query like</p>
  
  <pre><code>'select * from product_thumbnails where product in (873, 874, 875)'
  </code></pre>
  
  <p>The datatype for product is int. Are the params to the in() function treated as strings? If so, that would leave mysql to compare ints to strings and thus probably lead to a slow query as the app grows. Is there a way to typecast the params or to tell mysql to treat them as ints? Or is mysql smart enough to juggle this on its own?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Thanks much to Jerodev and jilesh for the answer- Mysql will treat these as ints. If you wanted a string instead, just use quotes inside the query string like </p>
  
  <pre><code>' in ("stringtype", "stringtype") '
  </code></pre>