1

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

p.v.g Sagar
  • 11
  • 1
  • 3

2 Answers2

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
-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