I have two queries
-
Query 1
-
SELECT COUNT(*) AS count FROM `comments` INNER JOIN `replies` ON `comments`.`comment_id` = `replies`.`reply_comm_id` WHERE CONCAT (`comment_message`, `reply_message`) LIKE ('%test%') AND `comments`.`comm_blog_id`=45;
Result
for "query 1"-
Query 2
-
SELECT (SELECT COUNT(*) FROM `comments` WHERE `comment_message` LIKE '%test%' AND `comm_blog_id` = 45) + (SELECT COUNT(*) FROM `replies` WHERE `reply_message` LIKE '%test%' AND `reply_blog_id` = 45) AS total_count;
Result
for "query 2"-
The following are the tables
-
"Comments" table-
"Replies" table-
Both have different results, but I think both "queries" are correct. Can anyone tell me which one I have to use for searching the data/string/tag/word/words (like- "test", or "test comment") from the two "tables"?
Suppose I have a tag
like test
or test comment
and I want to search this same tag
in both the replies
and comments
tables of the comment_message
and reply_message
rows and count
how many times it is coming/used.