Rebecca Rebecca -5 years ago 96
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download