title: Why does MySQL return rows that seemingly do not match the WHERE clause?
body: <p>suppose the user input</p>
  
  <pre><code>mysite.com/profile?identity=1
  mysite.com/profile?identity=dinodsja
  mysite.com/profile?identity=1a
  </code></pre>
  
  <p>getting the value</p>
  
  <pre><code>$identity = $_GET['identity']; // identity can be user_id or user_name
  </code></pre>
  
  <p>and i have a simple select query:</p>
  
  <pre><code>SELECT * FROM lb_users WHERE (user_id = 'dinodsja' OR user_name = 'dinodsja') AND user_status = 1
  </code></pre>
  
  <p>and it works fine. but the problem is:</p>
  
  <pre><code>SELECT * FROM lb_users WHERE (user_id = '1a' OR user_name = '1a') AND user_status = 1
  </code></pre>
  
  <p>when I execute this query it also returns the result <strong>without satisfying the condition</strong>.</p>
  
  <p>Table structure:</p>
  
  <pre><code>user_id     bigint(25)
  user_name   varchar(50)     utf8_general_ci
  </code></pre>
  
  <p><img src="https://I.stack.imgur.com/JADqR.jpg" alt="enter image description here"></p>
  
  <p>**</p>
  
  <pre><code>-&gt; Is this a MySQL Bug ? 
  -&gt; How can we avoid this ? 
  -&gt; What will be the query ?
  </code></pre>
  
  <p>**</p>