Mysql custom order by and alphabetical order by:

前端 未结 3 993
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-19 11:01

I am using the following query:

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

to select a

相关标签:
3条回答
  • 2020-12-19 11:43
    SELECT * FROM `$table[$a]` 
    ORDER BY 
      FIELD(typeof,'pdf','swf','img','web'), --first order by type
      filename  --then by filename
    
    0 讨论(0)
  • 2020-12-19 11:51
    $query = "SELECT * FROM `$table[$a]` ORDER BY FIELD(typeof,'pdf','swf','img','web'), name ASC";
    

    Not sure if that'll work

    0 讨论(0)
  • 2020-12-19 12:01
    ... ORDER BY FIELD(typeof,'pdf','swf','img','web'), name
    
    0 讨论(0)
提交回复
热议问题