Welcome Guest, Not a member yet? Register   Sign In
SQL Order By, excluding 'the'
#1

[eluser]bradya[/eluser]
Hi Guys,

I know this isn't a CI specific question, but though you might have some ideas on it. I am fetching a list of bands from a mysql table, and ordering by band name. Problem being that any band beginning with 'the' eg. 'The Sleepy Jackson' is automatically put as a 'T' rather than 'S'.

So, does anyone know of a way to order sql results, but to exclude words like 'the', kind of like stopwords in a full-text search I guess...
#2

[eluser]xwero[/eluser]
Code:
$this->db->order_by("REPLACE(bandname,'The ','')");
#3

[eluser]bradya[/eluser]
[quote author="xwero" date="1216323913"]
Code:
$this->db->order_by("REPLACE(bandname,'The ','')");
[/quote]

Thanks Xwero! Worked like a charm.




Theme © iAndrew 2016 - Forum software by © MyBB