GeoIP table join with table of IP's in MySQL

前端 未结 4 1757
终归单人心
终归单人心 2021-01-02 23:38

I am having a issue finding a fast way of joining the tables looking like that:

mysql> explain geo_ip;
+--------------+------------------+------+-----+---         


        
4条回答
  •  感情败类
    2021-01-02 23:40

    Can't comment yet, but user1281376's answers is wrong and doesn't work. the reason you only use the first octet is because you aren't going to match all ip ranges otherwise. there's plenty of ranges that span multiple second octets which user1281376s changed query isn't going to match. And yes, this actually happens if you use the Maxmind GeoIp data.

    with aleksis suggestion you can do a simple comparison on the fîrst octet, thus reducing the matching set.

提交回复
热议问题