0

I have the following query

SELECT *,MATCH(title,text) AGAINST('my home' in boolean mode) as relevance FROM blog where active = 1

The above query returns 5 rows with relevance 2,2,0,0,0

Now I want to select only the rows with maximum relevance. So it should return only the rows which has 2 as their relevance.

I tried the following query.

SELECT *,MATCH(title,text) AGAINST('my home' in boolean mode) as relevance FROM blog where active = 1 having relevance=max(MATCH(title,text) AGAINST('my home' in boolean mode))

But it returns only one row..

Is there any way to get only that two rows?

1 Answer 1

1
SELECT *, MATCH(title,text) AGAINST('my home' in boolean mode) as relevance 
FROM blog 
where active = 1
and MATCH(title,text) AGAINST('my home' in boolean mode) = (select max(MATCH(title,text) AGAINST('my home' in boolean mode)) from blog)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.