![]() If the IP would fall in a hole, no result will be returned. The second part of the query makes sure, it does not. If we search for a certain IP, it could fall into such a hole. Not yet assigned at the time the table was created. nip2 have holes in betweem them occasionally, for IP addresses which are Than makes sure that we are really in the interval. The second part of the query: and nip1 <= searched_ip #Ip2location database codeby writing the nonstandard SQL code 'limit 1'Īt the end of ther query, this potentially large set is cut down to one line. Select * from ipl where nip2 >= searched_ip and nip1 = searched_ipĭelivers a result set with the first row being what we search. LOAD DATA INFILE "PATHNAME/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ISP.CSV" INTO TABLE ipl FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' Note that nip2 (original name: ipTO ) is the only indexed column. Nip2 INT UNSIGNED PRIMARY KEY NOT NULL DEFAULT 0, I take the liberty to use my own table column names, instaed of those found in other examples. To make it easier for others with the same problem, I restate the complete problem and solution here. I found a solution to the problem in this forum, provided by Jared. Scans, if the example code which comes with the ip2location database is used. The mysql table definition and example code given in the documentation does not work efficiently with mysql,īecause the mysql optimizer isnot good with 'between' queries for large tables. provides databases for geographical location of IP addresses. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |