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?
custom ORDER BY
Moderator: General Moderators
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
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.
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.
Thanks for your time... I just found out how I wanted to do it
Code: Select all
ORDER by type='helm' DESC, type='amulet' DESC, type='cape' DESC, type='shield' DESC, type='weapon' DESC, type='bodyarmour' DESC