Page 1 of 1

custom ORDER BY

Posted: Fri Jan 30, 2004 7:12 am
by megaming
I want to ORDER BY a field named TYPE in this order: helm, amulet, shield, weapon, bodyarmour, boots.

Any idea how I would go about this?

Posted: Fri Jan 30, 2004 8:22 am
by microthick
Two suggestions:

1) Create a table that relates those items to numbers.

So you might have a table called Items:
helm | 1
amulet | 2
shield | 3

Etc. Then, instead, order by the ItemID not the ItemName.

2) This is more of a hack, but you could in the database call the helm, 1helm and the amulet, 2amulet. Then, just either remember to cut off the first letter before outputting it, or something. Then you can order by this type alphabetically.

Posted: Fri Jan 30, 2004 8:27 am
by megaming
Thanks for your time... I just found out how I wanted to do it :D

Code: Select all

ORDER by type='helm' DESC, type='amulet' DESC, type='cape' DESC, type='shield' DESC, type='weapon' DESC, type='bodyarmour' DESC