Force MATCH to return a certain number of results I am using MATCH in a query but sometimes the query returns no results. What can I do to force MATCH to return results, even if the results are not a match? I want the query to return four results. If the results are not a match then they should be random.

e.g. I want to get the two matches for the word 'Foo' plus two more random rows, making four results in total:

ID  TITLE
1   Carl
2   I am a title
3   Foo
4   Bar
5   Foobar
6   Title


The query should return something like:

ID  TITLE
3   Foo
5   Foobar
2   I am a title
6   Title


I tried:

SELECT
    *
FROM
    Entries
WHERE
    MATCH(Title) AGAINST("Foo")
UNION
    (
    SELECT
        *
    FROM
        Entries
    ORDER BY 
        RAND()
    )
LIMIT 4


I feel like this query should work, and it does, except the results that are not a match are not random for some reason, they are the same results every time.
Full Text Indexes don-'t work that way.

They find whole Words and combinations of those
Use instead the normal comparison LIKE to find your rows

The ORDER BY and the LIMIT have to be in the (),because mysql interprets them as belonging to the complete query (SELECT UNION SELCT)




SELECT
    *
FROM
    Entries
WHERE
    `Title` LIKE ('foo%')
UNION
(SELECT
    *
FROM
    Entries
WHERE
    ID NOT IN (SELECT ID
               FROM
                 Entries
               WHERE
                `Title` LIKE ('foo%'))
ORDER By Rand()
LIMIT 4)
;



ID | TITLE       
-: | :-----------
 3 | Foo         
 5 | Foobar      
 2 | I am a title
 4 | Bar         
 1 | Carl        
 6 | Title       






SELECT
    *
FROM
    Entries
WHERE
    `Title` LIKE ('foo%')
UNION
(SELECT
    *
FROM
    Entries
WHERE
    ID NOT IN (SELECT ID
               FROM
                 Entries
               WHERE
                `Title` LIKE ('foo%'))
ORDER By Rand()
LIMIT 2)
;



ID | TITLE 
-: | :-----
 3 | Foo   
 5 | Foobar
 4 | Bar   
 1 | Carl  



db&lt;>fiddle here