match
您可以在中重复order by
:
SELECT SQL_CALC_FOUND_ROWS id, autor, dle_post.date AS newsdate, dle_post.date AS DATE, short_story AS story, dle_post.xfields AS xfields, title, descr, keywords, category, alt_name, comm_num AS comm_in_news, allow_comm, rating, news_read, flag, editdate, editor, reason, view_edit, tags, '' AS output_comms
FROM dle_post
WHERE dle_post.approve =1
AND MATCH (
title, short_story, full_story, dle_post.xfields
)
AGAINST (
'test'
)
order by MATCH (title) AGAINST ('test') desc
LIMIT 0 , 30
顺便说一句,你不应该在没有limit
子句的情况下使用order by
。你可能想要的是更像这样的东西:
SELECT SQL_CALC_FOUND_ROWS id, autor, dle_post.date AS newsdate, dle_post.date AS DATE,
short_story AS story, dle_post.xfields AS xfields, title, descr, keywords,
category, alt_name, comm_num AS comm_in_news, allow_comm, rating, news_read, flag,
editdate, editor, reason, view_edit, tags, '' AS output_comms,
match(title, short_story, full_story, dle_post.xfields
) against ('test') as Relevancy
FROM dle_post
WHERE dle_post.approve =1
having Relevancy > 0
order by MATCH (title) AGAINST ('test') desc, Relevancy desc
LIMIT 0 , 30