Collections:
INET_NTOA() - IP Address Number to String
How to convert an IP address from number format to string using the INET_NTOA() function?
✍: FYIcenter.com
INET_NTOA(int) is a MySQL built-in function that
converts an IP address from number format to string.
It uses the following conversion formula:
INET_NTOA(int) = 'p1.p2.p3.p4' where: p1 = (int>>24) % 256 p2 = (int>>16) % 256 p3 = (int>>8) % 256 p4 = int % 256
For example:
SET @ip = 167773449; SELECT @ip, INET_NTOA(@ip); -- +-----------+----------------+ -- | @ip | INET_NTOA(@ip) | -- +-----------+----------------+ -- | 167773449 | 10.0.5.9 | -- +-----------+----------------+ SELECT (@ip>>24)%256, (@ip>>16)%256, (@ip>>8)%256, @ip%256; -- +---------------+---------------+--------------+---------+ -- | (@ip>>24)%256 | (@ip>>16)%256 | (@ip>>8)%256 | @ip%256 | -- +---------------+---------------+--------------+---------+ -- | 10 | 0 | 5 | 9 | -- +---------------+---------------+--------------+---------+
Reference information of the INET_NTOA() function:
INET_NTOA(int): ip Converts an IP address from number format to string. Arguments, return value and availability: int: Required. The IP address in number format. ip: Return value. The IP address as a string. Available since MySQL 4.0.
Related MySQL functions:
⇒ INET6_ATON() - IPv6 Address String to Number
⇐ INET_ATON() - IP Address String to Number
2023-12-19, 1177🔥, 0💬
Popular Posts:
What Happens If the UPDATE Subquery Returns Multiple Rows in MySQL? If a subquery is used in a UPDAT...
How To Calculate DATETIME Value Differences Using the DATEDIFF() Function in SQL Server Transact-SQL...
How To Generate CREATE VIEW Script on an Existing View in SQL Server? If you want to know how an exi...
How To Fix the INSERT Command Denied Error in MySQL? The reason for getting the "1142: INSERT comman...
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...