I'm displaying Spotlight post on search page.
When a user enters a keyword to search for a post I like to bring a Spotlight post using that keyword. If there is no post with that keyword then I would want to just bring any Spotlight post from database.
My questions is, can I check this in a MySQL query to see if they will be any results with this keyword, if not then ignore this keyword?
My query
SELECT id, title, desc
FROM post
WHERE isActive = 1
AND title = 'keyword'
but if I'm getting 0 results with this query I would like to ignore this and run this instead
SELECT id, title, desc
FROM post
WHERE isActive = 1