How to combine these two sql queries into one?
SELECT DISTINCT * FROM rss WHERE MATCH(content,title) AGAINST ('$filter')
SELECT COUNT(content) FROM rss WHERE MATCH(content,title) AGAINST ('$filters')
And if the result is 0 from the above query
–
SELECT DISTINCT * FROM rss WHERE content LIKE '%$filters%' OR title LIKE '%$filters%';
$filter .= $row['filter'];
$filters = $row['filter'];
$filters may be more than one keyword
You do not have to use query 2,
mysql_num_rowswill indicate how many rows for query 1, so just discard query 2if
mysql_num_rowsreturn zero, then proceed with query 3To combine three queries into one, use
ORAs explained above, you do not really need to do count first.
If $filter contains lots of keyword, then just repeating like