I have a database which stores IP address with its location. I only store the first 3 network ID of IP address in the table.
+-------------------+-----------------+
|ip_address(varchar)|location(varchar)|
+-------------------+-----------------+
| 1.2.3 | A |
| 1.2.4 | A |
| 1.22.33 | B |
| 1.100.99 | C |
+-------------------+-----------------+
Let say my IP is 1.2.3.4 or others 1.100.99.20, how do I compare the IP with the table to get the location?