Notes When querying IP address segments in mysql

Source: Internet
Author: User
Because of the preliminary design problems, when saving the ip address, it is not stored as an integer, but saved as a string. When querying the ip range, this problem occurs: selectipfromt_ipwhereipbetween192.168.11.1and192.168.11.150, when the last IP address is three digits, no data can be found.

Because of the preliminary design problems, when saving the ip address, it is not stored as an integer, but saved as a string. When querying the ip Range, this problem occurs: select ip from t_ip where ip between' 192. 168.11.1 'and' 192. 168.11.150 ', when the last IP address is three digits, no data can be found

<无>
Due to the preliminary design problems, when saving the ip address, it is not stored as an integer, but saved as a string. When querying the ip Range, this problem occurs: select ip from t_ip where ip between' 192. 168.11.1 'and' 192. 168.11.150 ', when the last IP address is three digits, no data can be found. Check that mysql comes with an inet_aton function that processes IP addresses. The function is mainly to provide a "Point address" (such as 127.0.0.1) representation of the network address that acts as a string, returns an integer representing the value of the address. The number generated is in the byte order. The preceding statement is changed to: select ip from t_ip where inet_aton (ip) between inet_aton ('192. 168.11.1 ') and inet_aton ('192. 168.11.150') to effectively compare the data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.