title: Is there way to match IP with IP+CIDR straight from SELECT query?
body: <p>Something like</p>
  
  <blockquote>
    <p><code>SELECT COUNT(*) AS c FROM BANS WHERE typeid=6 AND (SELECT ipaddr,cidr FROM BANS) MATCH AGAINST 'this_ip';</code></p>
  </blockquote>
  
  <p>So you don't first fetch all records from DB and then match them one-by one.</p>
  
  <p>If c > 0 then were matched.</p>
  
  <p>BANS table:</p>
  
  <pre><code>id int auto incr PK
  typeid TINYINT (1=hostname, 4=ipv4, 6=ipv6)
  ipaddr BINARY(128)
  cidr INT
  host VARCHAR(255)
  </code></pre>
  
  <p>DB: MySQL 5</p>
  
  <p>IP and IPv type (4 or 6) is known when querying.</p>
  
  <p>IP is for example ::1 in binary format</p>
  
  <p>BANNED IP is for example ::1/64 </p>