Hi!
I recently got a strange problem and I have no idea on the solution.
I try to do a ORDER BY statement with a fixed order of values, because
my client want's it this way.
My approach is like this:
$the_row = "'A', 'B', 'B b', 'C', 'D d', 'E'";
$q1 = mysql_query("SE LECT DISTINCT foo FROM $table WHERE bar =
'$kat_array[$bart]' ORDER BY $the_row") or die ("ERROR while 'SELECT'
all sub_kategorie from db! ->".mysql_error( ));
Now, what I get is not the expected order of
A
B
B b
C
D d
E
but something like
A
C
B b
E
D d
The result is not reflecting the order given by $the_row. It seems, it
orders some elements wrong. I tried several variations of the query
but nothing worked. I also tried it directly in phpMyAdmin with the
same, wrong result.
So my question is:
Is this a mistake done by me?
Is this a mistake in the MySQL query, meaning, it can't output a given
order?
Did I miss anything?
I hope someone can help.
Regards,
Rayden
I recently got a strange problem and I have no idea on the solution.
I try to do a ORDER BY statement with a fixed order of values, because
my client want's it this way.
My approach is like this:
$the_row = "'A', 'B', 'B b', 'C', 'D d', 'E'";
$q1 = mysql_query("SE LECT DISTINCT foo FROM $table WHERE bar =
'$kat_array[$bart]' ORDER BY $the_row") or die ("ERROR while 'SELECT'
all sub_kategorie from db! ->".mysql_error( ));
Now, what I get is not the expected order of
A
B
B b
C
D d
E
but something like
A
C
B b
E
D d
The result is not reflecting the order given by $the_row. It seems, it
orders some elements wrong. I tried several variations of the query
but nothing worked. I also tried it directly in phpMyAdmin with the
same, wrong result.
So my question is:
Is this a mistake done by me?
Is this a mistake in the MySQL query, meaning, it can't output a given
order?
Did I miss anything?
I hope someone can help.
Regards,
Rayden
Comment