我试图按比赛排序,但我无法这样做。我做错了什么?
SELECT * , (( image LIKE '%one%' ) + ( image LIKE '%two%' ))
AS matches
FROM images
ORDER BY matches
LIMIT 10
答案 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;