1

In one of my table column I have values like:

"fol v1.1.2",
"fol v1.2.10",
"fol v1.5.6",
"all fols",
"fol v1.7.10 updated 22.03.2019",
"fol v1.10.11"

After ordering i need the values like:

"all fols",
"fol v1.1.2",
"fol v1.2.10",
"fol v1.5.6",
"fol v1.7.10 updated 22.03.2019",
"fol v1.10.11"
1
  • 4
    You would need a pretty ugly query to swing this. For best results, I recommend storing the major and minor versions in separate number columns. This would make it very easy to sort the way you want. Commented Apr 2, 2019 at 4:59

1 Answer 1

3
select * from trial order by substring_index(dat,'.',1),cast(substring_index(substring_index(dat,'.',2),'.',-1) as signed),cast(substring_index(substring_index(dat,'.',3),'.',-1) as signed);

what i did is, split the versions in by '.' as a delimiter and then convert into integers then group them according to values.

for more information about splitting refer this w3resource-mysql-substring

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.