开发者

Mysql custom order by and alphabetical order by:

开发者 https://www.devze.com 2023-03-27 02:13 出处:网络
I am using the following query: $query = \"SELECT * FROM `$table[$a]` ORDER BY FIELD(typeof,\'pdf\',\'swf\',\'img\',\'web\')\";

I am using the following query:

$query = "SELECT * FROM `$table[$a]` ORDER BY FIELD(typeof,'pdf','swf','img','web')";

to select and customly order my mysql query, it works g开发者_开发问答reat except there are multiple files within each typeof and I now want to order them alphabetically yet retaining their typeof order. Make sense?


SELECT * FROM `$table[$a]` 
ORDER BY 
  FIELD(typeof,'pdf','swf','img','web'), --first order by type
  filename  --then by filename


$query = "SELECT * FROM `$table[$a]` ORDER BY FIELD(typeof,'pdf','swf','img','web'), name ASC";

Not sure if that'll work


... ORDER BY FIELD(typeof,'pdf','swf','img','web'), name
0

精彩评论

暂无评论...
验证码 换一张
取 消