KGodel
03-11-2015, 03:14 PM
Hello friends.
I am trying to sort the results of a MySQL query I am processing. Here is some background.
I have a list of possible values for a column. This list has 3 values that are always possible, the rest of the values can changed. I want to sort by this column, but in a specific way.
I know I can do ORDER BY FIELD(bla, 'val1', 'val2'), bla ASC
My question is this. Of the three values that are always variable, I want two at the top of the sort order and one at the bottom. Is this possible? Basically, sort should look like this:
ForeverValue1
ForeverValue2
Variables ASC
..
..
ForeverValue3
(If you want to know why I want this its because I am generating a dynamic page but I want to use as few loops as possible. I could easily loop through these fields how I wanted in php but if I can sort them beforehand it will save me on code and pageload time.)
I am trying to sort the results of a MySQL query I am processing. Here is some background.
I have a list of possible values for a column. This list has 3 values that are always possible, the rest of the values can changed. I want to sort by this column, but in a specific way.
I know I can do ORDER BY FIELD(bla, 'val1', 'val2'), bla ASC
My question is this. Of the three values that are always variable, I want two at the top of the sort order and one at the bottom. Is this possible? Basically, sort should look like this:
ForeverValue1
ForeverValue2
Variables ASC
..
..
ForeverValue3
(If you want to know why I want this its because I am generating a dynamic page but I want to use as few loops as possible. I could easily loop through these fields how I wanted in php but if I can sort them beforehand it will save me on code and pageload time.)