I have a wordpress table wp_postmeta and what I want is a list of all posts where sttf_split_test_status = 'active'
but it CAN NOT have another meta row with the same post_id and a meta_key of stti_winner
set. My below code returns empty, but there should be a result.
SELECT DISTINCT post_id
FROM wp_postmeta
WHERE meta_key = 'sttf_split_test_status'
AND meta_value = 'active'
AND NOT EXISTS (
SELECT post_id
FROM wp_postmeta
WHERE post_id = post_id
AND meta_key = 'stti_winner'
)
LIMIT 0, 25