Answer the question
In order to leave comments, you need to log in
How to calculate ip-addresses using only sql?
We have a Mysql database at work. It has the following columns (description - name - field type):
1. Subnet IP address - IpAddr - INT
2. Subnet mask - Mask - INT
3. First subnet host - StartIp - INT
4. Subnet broadcast - EndIp - INT
5 Point Id from another table - IdFilial - INT
Ip addresses are stored as Integer and are converted back and forth by the native command INET_ATON and INET_NTOA.
If you want to find which network the ip address corresponds to, then a request is created containing approximately the following condition
WHERE StartIp < $Ipaddress AND EndIp > $Ipaddress
Answer the question
In order to leave comments, you need to log in
IpAddress & Mask = IpAddr
(assuming the IP is guaranteed to be real and you don't have to find out if it's a real address or one of the service ones associated with the network)
Perhaps - I don't know how big the table is - the database is kept in this form for the sake of indexing.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question