Answer the question
In order to leave comments, you need to log in
How to sort a table by matching multiple rows?
Dear GURU and pro SQL, give advice please.
There is a sequence of lines: "Table", "Chair", "Puff".
As you can see, the sequence is not in alphabetical order,
So here's how to sort the table so that 1/3 are Tables, 1/3 Chairs, 1/3 Ottomans
And so that they are displayed only in this order.
SELECT * FROM mebel WHERE type="Стол"
UNION
SELECT * FROM mebel WHERE type="Стул"
UNION
SELECT * FROM mebel WHERE type="Пуфик"
Answer the question
In order to leave comments, you need to log in
Forcing you to watch a video is not a good person)))
1.
remote here ip- IP address of the router hopefully. In the video, for example, 176.122.115.66 is indicated. This IP is issued by the provider (white IP) for your ASUS.
do you have white or grey?
true grey! and the gray ip for the internet has no routing
found.
SELECT * FROM mebel
ORDER BY
CASE type
WHEN 'Стол' THEN 1
WHEN 'Стул' THEN 2
WHEN 'Пуфик' THEN 3
ELSE 4
END ASC,
name ASC;
SELECT * FROM mebel
ORDER BY FIELD(type, 'Стол', 'Стул', 'Пуфик');
SELECT * FROM mebel
ORDER BY FIND_IN_SET(type, 'Стол,Стул,Пуфик');
SELECT *
FROM mebel
ORDER BY CAST(name AS UNSIGNED), name;
natsort($array);//аналогично для PHP
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question