To put my question into perspective:
I have a PHP app, which stores IP's of users in a MySQL table.
The column type is VARBINARY(16), and the app uses PHP's inet_pton to form a binary string.
That is the string has 4 bytes for a typical IP4 address.
How to retrieve these IPs from the table, displaying them in a human readable form?
My current solution is:
select INET_NTOA(CONV(HEX(ip),16,10)) from operation_ip;
Is there a more direct way to do that?
In particular is CONV(HEX(x),16,10) the easiest way to change 4 bytes into an integer (actually I believe it is not even an integer, but a string which looks like integer).
(I use VARBINARY(16), as PHP's inet_pton can return 16-bytes for IPv6 addresses. AFAIK MySQL's INET_NTOA does not support IPv6, but at the moment this is not my biggest concern).