Answer the question
In order to leave comments, you need to log in
How to sort correctly in sql?
Good afternoon,
tell me how to formulate the query correctly, there is a table with columns: pc_name, ip, db_name, action,
I need to embed an if condition,
for example, if pc_name = 1, ip=2, db_name=3,
only then do not display them in the result.
Answer the question
In order to leave comments, you need to log in
The easiest way is to find out with a case whether a particular row needs to be displayed in the query, and then select only those that do not fall into the condition. Something like this:
select * from (
select
case
when (pc_name = 1 and ip=2 and db_name = 3) then 0
else 1
end sort,
...
from table
) q
where sort = 1
If I understand the question correctly then:
Or (if on the contrary, this data is not needed)
Or
Selection sort is ORDER BY `column`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question