I need a RAW SQL, as I am working from different platform with WordPress Database.
When I run example.com/tag/first+second, WordPress runs a query SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (10649,7783,6336,4556,3938)
Where did this get the post IDs? I am only guessing. I do have certain thoughts about it, but first want to see if someone knows.
Here is the query I have built when getting posts by SINGLE tag:
SELECT `wp_posts`.`ID`, `wp_posts`.`post_name`, `wp_posts`.`post_title`, `wp_posts`.`post_date`, `wp_posts`.`post_content` , DATEDIFF(CURDATE(),post_date) as days_ago
FROM `wp_posts`
INNER JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy
ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
INNER JOIN wp_terms
ON (wp_term_taxonomy.term_id = wp_terms.term_id)
WHERE 1=1
AND wp_term_taxonomy.taxonomy = 'post_tag'
AND wp_terms.slug SOUNDS LIKE 'Hennessy'
AND wp_terms.slug SOUNDS LIKE 'VS'
AND wp_posts.post_type = 'post'
AND (wp_posts.post_status = 'publish')
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC
thanks.
