George Reith
George Reith

Reputation: 13476

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?

Upvotes: 6

Views: 1128

Answers (3)

nobody
nobody

Reputation: 10635

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

Upvotes: 2

Prisoner
Prisoner

Reputation: 27618

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

Not sure if that'll work

Upvotes: 2

Mchl
Mchl

Reputation: 62359

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

Upvotes: 10

Related Questions