Here is the IPV6 address in a table in SQL database,
I want to compare these two IPV6 addresses
From Range: 2002:4559:1FE2:4559:1FE2:21E3:F3E3:0051
To Range: 2002:4559:1FE2:4559:1FE2:21E3:F3E3:0055
Need to compare those addresses and then update the
To range address to the From range address in that table.Please help
Asked
Active
Viewed 1,175 times
1
p.v.g Sagar
- 11
- 1
- 3
-
there are other options than this two? In future? Or only two addresses to make that range? – Whencesoever Mar 01 '17 at 07:39
2 Answers
1
If you're using MySQL >5.6.3, you could use INET6_ATON to convert the string to a VARBINARY(16) and use that for a range check? A lexicographical string comparison might also work for you if these are addresses are all stored in a uniform way.
See also Storing IPv6 Addresses in MySQL
Community
- 1
- 1
Paul Dixon
- 295,876
- 54
- 310
- 348
-
Thanks for the reply,But i didnt get you sir,COuld you plz write a querey instead – p.v.g Sagar Mar 01 '17 at 08:40
-1
Calculates an MD5 128-bit checksum for the two ranges and compare the checksum instead the ranges. The value(checksum) is returned as a string of 32 hexadecimal digits, or NULL if the argument was NULL.
Sample query:
UPDATE Table T1
SET T1.To_Range = T1.From_Range
WHERE MD5(T1.From_Range) != MD5(T1.To_Range)
simhumileco
- 31,877
- 16
- 137
- 115
narendra solanki
- 374
- 2
- 8