I think you could do something like:
order by p.`No`, `Relation`='Self', `Relation`='Husband', `Relation`='Son'
Expression Relation='Self', Relation='Husband', Relation='Son'return 0, or 1(in the order of adding) depending on whether or not satisfied. Thus, it can generate the required order
You can also use the FIELD function of MySQL as:
order by p.`No` ASC, FIELD(`Relation`,'Self,Husband,Son') ASC
source
share