Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
653 views
in Technique[技术] by (71.8m points)

php - Mysql custom order by and alphabetical order by:

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 great except there are multiple files within each typeof and I now want to order them alphabetically yet retaining their typeof order. Make sense?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...