匹配的MYSQL排序无效

时间:2016-01-06 03:18:32

标签: php mysql database select mysqli

我试图按比赛排序,但我无法这样做。我做错了什么?

SELECT * , (( image LIKE  '%one%' ) + ( image LIKE  '%two%' )) 
AS matches
FROM images
ORDER BY matches
LIMIT 10

1 个答案:

答案 0 :(得分:3)

我的猜测是你想要matches DESC中的ORDER BY

SELECT i.*,
       (( image LIKE  '%one%' ) + ( image LIKE  '%two%' ))  as matches
FROM images i
ORDER BY matches DESC
LIMIT 10;