2,187
edits
(→Migrate Databases: Added "Create Blank Copy") |
(→IP Addresses: Added get-out for binary string gotcha) |
||
Line 96: | Line 96: | ||
SELECT INET_NTOA(ip) from ips WHERE INET_NTOA(ip) LIKE '10.1.2.%'; | SELECT INET_NTOA(ip) from ips WHERE INET_NTOA(ip) LIKE '10.1.2.%'; | ||
</source> | </source> | ||
Alternatively, use VARCHAR(15) to store as text. | Alternatively, use <code>VARCHAR(15)</code> to store as text. | ||
The data returned by <code> INET_NTOA() </code> is in binary string format, which can occasionally cause problems. If you're passing the data into PowerShell, for example, you end up by a <code> [byte] </code> object that is nigh on impossible to convert to a standard string. To force MySQL to return a string wrap the command in <code>CONVERT(x, CHAR)</code>, eg | |||
<source lang="mysql"> | |||
SELECT CONVERT(INET_NTOA(ip), CHAR) AS ip from ips; | |||
</source> | |||
== CREATE / ALTER Tables == | == CREATE / ALTER Tables == |