How are mysql multi-field OR queries sorted?

existing table user

data structure
id name sex age
1 B 2 20
2 A 2 25
3 B 1 20
4 A 1 30

select * from user where name ="A"or sex ="1" can find data

2 A 2 25
3 B 1 20
4 A 1 30

from the point of view of the above data, the data with an id of 4 have the highest degree of matching. How to sort the data with the highest degree of matching (multi-fields).

Mar.22,2021

in fact, this problem can be regarded as a mathematical set problem
your sql:

select * from user where name = 'A' or sex = '1' 

can be equivalent to the following sql

select * from user where name = 'A' AND sex = 1 
UNION ALL
SELECT * FROM user WHERE name = 'A' AND sex != 1
UNION ALL
SELECT * FROM user WHERE name != 'A' AND sex = 1

split into three parts, you can freely adjust the display order
Thank you.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3f211-2c483.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3f211-2c483.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?