title: Getting id from url column in Mysql
body: <p>I have a Mysql table like this:</p>
  
  <pre><code>url
  ---------------
  example.com/test.php?id=5
  example.com/test.php?id=6&amp;serial=10
  example.com/test.php?subsid=7
  example.com/test.php?id=7&amp;serial=10&amp;subsid=4
  example.com/test.php?subsid=9&amp;serial=10&amp;id=8
  </code></pre>
  
  <p>I want to extract id from the url column. So far I have done the following:</p>
  
  <pre><code>select url,substring_index(substring_index(url, 'id=', -1),'&amp;', 1) from thetable
  </code></pre>
  
  <p>But the problem is it gets 7 for the third row too which I dont want. I want to get id only not subsid etc.</p>
  
  <p>One more thing, I want to do it without any PHP.</p>
  
  <p>Thanks in advance.</p>