Welcome Guest, Not a member yet? Register   Sign In
Problem with order_by
#1

[eluser]bondjp[/eluser]
I'm having a bit of a problem using order_by.
I'm trying to oder one field but i want that the first value to be assigned by me like this:

carbrand
Lamborghini -> Assigned by me
Alfa Romeo
Aston Martin
Audi
BMW
....

Using this:
Code:
$this->db->order_by('carbrand', 'asc');

How can i use the order_by to achieve this?
Thanks.
#2

[eluser]WanWizard[/eluser]
You can do that with an intermediate field:
Code:
SELECT * FROM table ORDER BY CASE carbrand WHEN "Lamborghini" THEN 0 ELSE 1 END ASC, carbrand ASC
#3

[eluser]bondjp[/eluser]
[quote author="WanWizard" date="1274873449"]You can do that with an intermediate field:
Code:
SELECT * FROM table ORDER BY CASE carbrand WHEN "Lamborghini" THEN 0 ELSE 1 END ASC, carbrand ASC
[/quote]

THANKS!




Theme © iAndrew 2016 - Forum software by © MyBB