mysql order by 固定_[MySQL] ORDER BY具有固定值

bd96500e110b49cbb3cd949968f18be7.png

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("SELECT 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

解决方案the_row = "''A'', ''B'', ''B b'', ''C'', ''D d'', ''E''";

q1 = mysql_query("SELECT DISTINCT foo FROM

table WHERE bar =

''

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值