A
A
artmirarmi2018-02-10 04:47:55
MySQL
artmirarmi, 2018-02-10 04:47:55

How to get all fields from the database?

Let's say we have an articles table. It has fields id, name, description, category, etc.
How to get all the fields from the database, but so that the fields with category=1 and category=3 are first, and then all the rest?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Varyukhin, 2018-02-10
@Hocopor

SELECT * FROM articles ORDER BY FIELD(category, 3, 1) DESC;

Example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question