If you need all messages with a specific tag, then why did you specify the message identifier in the request?
In the next request, all messages with the specified tag identifier will be displayed
SELECT wposts.ID AS ID, wposts.post_title, wposts.post_status, wposts.post_name, tag_terms.term_id AS tag_id FROM `wp_posts` AS wposts INNER JOIN wp_term_relationships AS tag_term_relationships ON (wposts.ID = tag_term_relationships.object_id) INNER JOIN wp_term_taxonomy AS tag_term_taxonomy ON (tag_term_relationships.term_taxonomy_id = tag_term_taxonomy.term_taxonomy_id AND tag_term_taxonomy.taxonomy = 'post_tag') INNER JOIN wp_terms AS tag_terms ON (tag_term_taxonomy.term_id = tag_terms.term_id) WHERE wposts.post_type = 'post' AND wposts.post_status NOT LIKE 'private' AND tag_terms.term_id = '55' GROUP BY wposts.ID ORDER BY wposts.post_date ASC
Now, if you want these messages to have only the specified tag identifier, insert the query as follows:
SELECT wposts.ID AS ID, wposts.post_title, wposts.post_status, wposts.post_name, tag_terms.term_id AS tag_id FROM `wp_posts` AS wposts INNER JOIN wp_term_relationships AS tag_term_relationships ON (wposts.ID = tag_term_relationships.object_id) INNER JOIN wp_term_taxonomy AS tag_term_taxonomy ON (tag_term_relationships.term_taxonomy_id = tag_term_taxonomy.term_taxonomy_id AND tag_term_taxonomy.taxonomy = 'post_tag') INNER JOIN wp_terms AS tag_terms ON (tag_term_taxonomy.term_id = tag_terms.term_id) WHERE wposts.post_type = 'post' AND wposts.post_status NOT LIKE 'private' AND tag_terms.term_id = '55' GROUP BY wposts.ID HAVING COUNT( tag_terms.term_id ) <> 1 OR MAX( tag_terms.term_id ) <> 55 ORDER BY wposts.post_date ASC
source share