Created
October 30, 2013 08:41
-
-
Save leoken/7229121 to your computer and use it in GitHub Desktop.
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 * | |
FROM ( | |
SELECT | |
`wp_posts`.`ID` , | |
`wp_posts`.`post_title` AS `Title`, | |
`wp_posts`.`post_date` AS `Date`, | |
MAX( CASE WHEN `wp_postmeta`.`meta_key` = 'useremail' | |
THEN `wp_postmeta`.`meta_value` | |
END ) AS `Email`, | |
MAX( CASE WHEN `wp_postmeta`.`meta_key` = 'usercell' | |
THEN `wp_postmeta`.`meta_value` | |
END ) AS `Cell Phone`, | |
concat('http://yoururl.com/?p=',`wp_posts`.`ID`) as `URL` | |
FROM `wp_posts` | |
LEFT JOIN `wp_postmeta` ON ( `wp_posts`.`ID` = `wp_postmeta`.`post_id` ) | |
WHERE `wp_posts`.`post_status` = 'publish' | |
AND `wp_posts`.`post_type` = 'customposttype' | |
GROUP BY `wp_posts`.`ID` | |
ORDER BY `wp_posts`.`post_date` DESC | |
) AS `t` WHERE 1 =1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment