Reputation: 101
I have a mysql phpbb database, one of its tables, has a title column, which content is like "[data] moredata (info)"
I want to order that table in alphabetic order, but using only the "moredata" string of the title, obviating de [data] and (info)
for example:
[article] Advise for dummies (pdf)
[Review] Star wars (selfWrote)
[film] The Avengers (trailer)
and get the mysql table ordered like this:
[article] Advise for dummies (pdf)
[film] The Avengers (trailer)
[Review] Star wars (selfWrote)
using on every row, "Advise for dummies" , "The Avengers" , "Star wars" as the elment to get the alphabetic order.
Could anyone help me with that? if its not possible, Can I do it with PHP?
Upvotes: 1
Views: 54
Reputation: 1031
Try this:
SELECT * FROM table ORDER BY SUBSTR(title, POSITION("]" IN title) + 1, ((POSITION("(" IN title)) - POSITION("]" IN title) - 1)) ASC
Upvotes: 1