A
A
Amoled2015-01-20 19:08:36
PHP
Amoled, 2015-01-20 19:08:36

How best to sort?

Good afternoon.
A query to the MySQL database (without sorting the result) returns a list:

Sword Art Online 1 ED
Sword Art Online 1 OP
Sword Art Online 2 ED
Sword Art Online 2 OP
Sword Art Online Movie ED
Sword Art Online 2 OST

You should end up with something like this:
Sword Art Online 1 OP
Sword Art Online 1 ED
Sword Art Online 2 OP
Sword Art Online 2 ED
Sword Art Online 2 OST
Sword Art Online Movie ED

Tell me how you can do this as quickly as possible using PHP or SQL (or together). Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2015-01-20
@Sanasol

Add column order.
Or adding [1] [2] [3] at the beginning of each name might help.

D
Dmitry Bay, 2015-01-20
@kawabanga

Do you need additional sorting on the last field?
ORDER BY FIELD(priority, 'OP', ED', 'OST');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question