and the scores need to be added up across challenges. that’s where I’m getting stuck…
this seems to be getting close:
SELECT p . * , s . *
FROM wp_posts p
JOIN wp_postmeta s ON s.meta_key = 'score_value'
WHERE p.id = s.post_id
AND 1 = 1
AND p.post_type = 'challenge_one'
OR p.post_type = 'challenge_two'
OR p.post_type = 'challenge_three'
AND (
p.post_status = 'publish'
)
ORDER BY s.meta_key ASC;
but the ordering doesn’t seem to be right.
anyone have any ideas?
messing around, I’ve got this far:
SELECT p . * , s . *
FROM wp_posts p
JOIN wp_postmeta s ON p.id = s.post_id
WHERE 1 =1
AND p.post_type = 'challenge_one'
OR p.post_type = 'challenge_two'
OR p.post_type = 'challenge_three'
AND (
p.post_status = 'publish'
)
ORDER BY p.post_date DESC