I have a field in my table which contains categories data eg
Computer > Mouse
Computer > Keyboard
Archived Game > Strategy
PS3 > Game > sports
when I pull them out of the table I strip all but the last word using:
$category = trim(substr($databack20[main_category], strrpos($databack20[main_category], '>') + 1));
Which works perfectly.
I need to pull these out of the table, in name order
So currently I get:
Archived Game > Strategy
Computer > Keyboard
Computer > Mouse
PS3 > Game > Sports
But the order I need is:
Keyboard
Mouse
Sports
Strategy
Is there a way to do this within the query? If so how, if not is there another way?
While I do agree with the answers, you should split out the string into separate fields, you can sort it as you’d like, although performance will not be very good. Try this