mysql sort with FIND_IN_SET

if you want to sort a colum  not with the standard up/ down order, you can use FIND_IN_SET in ORDER BY.

The functzion Find_in_set:

SELECT FROM FIND_IN_SET(“b”, “a,b,c”)

Just return 2, the position where matched.

Use in ODER BY Example:

SELECT * FROM Product

WHERE id IN ( 6,5,4)

ORDER BY FIND_IN_SET(id, “6,5,4”)

 

mysql sort with FIND_IN_SET》有一个想法

评论已关闭。