title: MySQL query to convert CIDR into IP range
body: <p>I have a table which contains a column as CIDR values like <code>1.0.85.128/25</code>, I have 2 other columns (start_ip_range and end_ip_range), I want to populate those 2 column FROM CIDR column</p>
  
  <p>Java code might look like as follows:</p>
  
  <pre><code>String[] parts = cidr.split("/");
  String ip = parts[0];
  int prefix;
  if (parts.length &lt; 2) {
      prefix = 0;
  } else {
      prefix = Integer.parseInt(parts[1]);
  }
  
  String[] ipParts = ip.split("\\.");
  int address = ((new Integer(ipParts[0]) &lt;&lt; 24) &amp; 0xFF000000) 
      | ((new Integer(ipParts[1]) &lt;&lt; 16) &amp; 0xFF0000) 
      | ((new Integer(ipParts[2]) &lt;&lt; 8) &amp; 0xFF00) 
      | (new Integer(ipParts[3]) &amp; 0xFF);
  int mask = (-1) &lt;&lt; (32 - prefix);
  int start = address &amp; mask;
  int end = start + (~mask);
  </code></pre>
  
  <p>How this can be transformed into MySql Query.</p>