mysql - Sort query results alphabetically, but exclude "the" in sorting? -
let's have laravel 4 application. let's have populated movies table.
this:
$movies = movie::orderby('title', 'asc')->get();
returns this:
braveheart silent hill big lebowski waterworld
what i'd though, ignore "the" in sort return this:
the big lewbowski braveheart silent hill waterworld
is there inside laravel make easy? how approach this? need write custom sql query?
thanks!
i not know laravel, query may want:
select title movies order case when substring(title 1 4) = 'the ' substring(title,5) else title end desc
the other answer referring replace
function might enough, note replace
replace occurrences of target string (for example "gone wind" changed.
Comments
Post a Comment