Published in: SQL
URL: http://www.petefreitag.com/item/619.cfm
Sometimes you need TO think backwards. Here was the problem. I needed TO match up some IP address ranges TO the company that owns them. Looking FOR a simple solution TO the problem I came up WITH storing the IP address block patterns IN the DATABASE AS follows: ip_pattern ---------------- 127.%.%.% 192.168.%.% 10.%.%.% Any idea why I choose % AS the wildcard? That's right - it's the wildcard operator IN SQL FOR the LIKE statement. So now when I have have an IP address 192.168.1.1, I can do what I LIKE TO call a backwards LIKE query: SELECT company, ip_pattern FROM company_blocks WHERE '192.168.1.1' LIKE ip_pattern This works ON SQL Server AND MySQL, AND I would think it should work fine ON any DATABASE server.
You need to login to post a comment.
