title: MySQL treats string as integer
body: <p>I have huge problem with my application. Before I start I red these subjects <a href="https://stackoverflow.com/questions/17843329/mysql-treating-varchar-as-int-bug">Mysql treating varchar as int bug?</a>, and <a href="https://stackoverflow.com/questions/24762038/mysql-autocasting-string-to-integer">mysql autocasting string to integer</a>.</p>
  
  <p>My table:</p>
  
  <pre><code>CREATE TABLE `srv_table` (
    `srv_id` int(11) NOT NULL AUTO_INCREMENT,
    `srv_code` char(4) NOT NULL,
    `name` varchar(255) NOT NULL,
    PRIMARY KEY (`srv_id`),
    UNIQUE KEY `code` (`srv_code`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>When i try to select rows by primary key and send mixed string it returns me results. Example:</p>
  
  <pre><code>SELECT * FROM srv_table WHERE srv_id='2sadf'
  </code></pre>
  
  <p>will return same result as:</p>
  
  <pre><code>SELECT * FROM srv_table WHERE srv_id=2
  </code></pre>
  
  <p>I know that this is documented in MySQL, but I couldn't find how i can avoid that. Is there a setting or something else I could do <strong>without change my code and queries</strong>?</p>
  
  <p>Regards.</p>
  
  <p><strong>UPDATE:</strong>
  For these guys that don't beleive that it returns same result when id value is wrapped by single quotes:</p>
  
  <p><a href="http://sqlfiddle.com/#!2/0e9289/1" rel="nofollow noreferrer">SQL fiddle</a></p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>It seems this is not an issue in PostgreSQL:
  <a href="http://sqlfiddle.com/#!15/352fa0/2" rel="nofollow noreferrer">PgSQL fiddle</a></p>