Skip to content
Advertisement

How do I sort a table with non alphabetical values?

I’m a non-programmer and want to use the power of SQL to sort my inventory data. Here’s the sample table that I have.

I want to turn this data to this. How can I query my table to have a result like this below

Advertisement

Answer

These two suggestions – if stick to the datasets given.

If you’re on MySQL 8++ or MariaDB 10.3+, you can use REGEXP_REPLACE like this:

If you’re using older MySQL version:

Demo fiddle

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement