Created
May 7, 2015 06:39
-
-
Save qutek/84c6242a27d3cbbf983c to your computer and use it in GitHub Desktop.
[Wordpress][Database] Display meta_value as column
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT p.ID, p.post_type, p.post_status, m.* FROM wp_posts p LEFT JOIN | |
( SELECT | |
post_id, | |
GROUP_CONCAT(if(meta_key = 'campaign_description', meta_value, NULL)) AS 'description', | |
GROUP_CONCAT(if(meta_key = 'campaign_start', meta_value, NULL)) AS 'start', | |
GROUP_CONCAT(if(meta_key = 'campaign_end', meta_value, NULL)) AS 'end', | |
GROUP_CONCAT(if(meta_key = 'campaign_priority', meta_value, NULL)) AS 'priority' | |
FROM wp_postmeta | |
GROUP BY post_id ) m | |
ON m.post_id = p.ID | |
WHERE p.post_type = 'campaign' AND p.post_status = 'publish' | |
AND m.start = '05/07/2015' | |
AND m.end = '05/20/2015' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment