I'm trying to sort a MySQL table data based on a column values.
| id | record_number | created_at | updated_at |
|---|---|---|---|
| 1 | ent/4/2022 | 2022-10-24 20:34:25 | 2022-10-24 20:34:25 |
| 3 | ent/6/2021 | 2022-10-24 20:35:03 | 2022-10-24 20:35:03 |
The column is named record_number and the values of column follow the format ent/4/2022, where ent is common in all entries and 4 is the record number and 2022 is the year the record was created.
How can I sort the records in a MySQL query such that an entry like ent/6/2021 shows up before ent/4/2022 when displaying the sorting results in ascending order?
The sorting result in descending order should look something like this.
| id | record_number | created_at | updated_at |
|---|---|---|---|
| 1 | ent/4/2022 | 2022-10-24 20:34:25 | 2022-10-24 20:34:25 |
| 3 | ent/6/2021 | 2022-10-24 20:35:03 | 2022-10-24 20:35:03 |
This implies the record id = 1 is newer compared to record with id = 3 because it was created in 2021 and the latter in 2022.