Created
February 19, 2016 09:32
-
-
Save maicong/4bad738e7a3387fc8e21 to your computer and use it in GitHub Desktop.
提取 WP 文章数据库信息
This file contains 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 | |
unix_timestamp(p.post_date) AS created, | |
p.post_content AS text, | |
p.post_title AS title, | |
p.post_name AS slug, | |
m.thumbnail | |
FROM | |
wp_posts AS p | |
LEFT JOIN ( | |
SELECT | |
m2.post_id AS post_id, | |
m1.meta_value AS thumbnail | |
FROM | |
wp_postmeta AS m1 | |
JOIN ( | |
SELECT | |
wp_postmeta.post_id AS post_id, | |
wp_postmeta.meta_value AS thumbnail_id | |
FROM | |
wp_postmeta | |
WHERE | |
wp_postmeta.meta_key = '_thumbnail_id' | |
) AS m2 ON m1.post_id = m2.thumbnail_id | |
WHERE | |
m1.meta_key = '_wp_attached_file' | |
) AS m ON p.ID = m.post_id | |
WHERE | |
p.post_author = 1 | |
AND p.post_status = 'publish' | |
AND p.post_type = 'post' | |
ORDER BY | |
p.ID ASC |
Author
maicong
commented
Apr 15, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment