Rebecca Rebecca - 1 year ago 37
MySQL Question

how to get a greater value with numbers containing 2 decimal points

is there any way we can find which is a greater version i.e to find if 1.0.1 is greater than 1.0.13 in php or mysql...

Any help appretiated,
Thank You

Answer Source

version_compare is a builtin PHP function used for exactly that (comparing version numbers); that'll do what you're asking.

version_compare('1.0.1', '1.0.13'); // -1
version_compare('1.0.1', '1.0.1'); // 0
version_compare('1.0.13', '1.0.1'); // 1

From the docs:

version_compare() returns -1 if the first version is lower than the second, 0 if they are equal, and 1 if the second is lower.