Filippo oretti
Filippo oretti

Reputation: 49817

Mysql query Match and OR WHERE

hi if have this query:

 SELECT *,
      MATCH(tags) AGAINST ('book library' IN BOOLEAN MODE) AS resources_score 
      FROM books  HAVING resources_score > 0 
      ORDER BY resources_score DESC, id DESC ; 

is it possible to add a OR WHERE title LIKE ;

Also since my query is returnig resource_score as 1 or 0 , is it possible to have a more query/search/results accuracy?

In the end, one tip dubt, query match accuracy depends on number of records?

thanks to who will help me

Upvotes: 1

Views: 66

Answers (1)

histocrat
histocrat

Reputation: 2381

When all else fails, you can combine SQL functions using arithmetic.

 SELECT *,
 (title LIKE '%pattern%') + (MATCH(tags) AGAINST ('book library' IN BOOLEAN MODE))
   AS resources_score 
 FROM books HAVING resources_score > 0 
 ORDER BY resources_score DESC, id DESC ;

This will add 1 to the score returned by MATCH() when the title contains 'pattern'.

Upvotes: 1

Related Questions