I’m working with an external CSV product feed that is imported into a database, the results of each row are displayed to the end-user in a comparison table.
A particular column holds numerous details that I wish to sort by independently. The feed/table structure cannot be changed.
Example of the db feed table:
MODEL | SPECIFICATIONS | AGE
Car 1A | 1000 miles recorded, 10 previous owners, No tax included | 3 years
Car 1B | 1000 miles recorded, 5 previous owners, No tax included | 5 years
Car 1C | 6000 miles recorded, 7 previous owners, No tax included | 5 years
Bike 1D | 3000 miles recorded, 5 previous owners, 100 tax included | 4 years
Currently my mysql_query uses an ‘ORDER BY model’ statement.
I’d like to display the comparison table sorted by the number of ‘previous owners’ within the SPECIFICATIONS column.
Is there a way to do this within an ORDER BY statement?
Thanks for your time.
I tested your table setup in a dummy
MySQLdatabase and came up with the following solution.It assumes that the specifications field has at least two sections separated by , and that there is a space between the number of owners and the text “previous owners”.