1

Does anyone know how to use a lookup table to find IP addresses in sql?

In sqlite manager, I have a lookup table, country_ip, that has the ranges of IP addresses, variables start and end, and a variable with the corresponding country. The IP was converted into an integer. In another table, simple_english, I have the actual IP address as an integer, ip_convert. How in sql can I take the IP address ip_convert and search the ranges in the other table to find the country, and then populate the former table? I can't seem to figure it out. I was thinking of coding something like:

update simple_english
set simple_english.country = country_ip.country 
from simple_english, country_ip

where simple_english.ip_convert
BETWEEN country_ip.start AND country_ip.end 
from simple_english, country_ip;

But, I'll welcome any suggestions. Thanks!

Tom

Tom Stieve
  • 31
  • 2

0 Answers0