2017-11-10 6 views
0

すべての投稿をリビジョンとともにエクスポートしようとしています。だから私はいつ何が変わったのか、誰が変わったのかを見ることができます。リビジョンデータを含むすべての投稿を取得するSQLクエリ

どうすればいいのか分かりません。今までの私の質問: -

select p.id, p.post_parent, p.post_title 
from wp_posts p 
join wp_posts p1 on p.id=p1.post_parent 
where post_type in ('hg-scratch-card','revision') and 
post_status='publish'; 

しかし、それは動作していないようです。

これに関するヘルプは本当に感謝します。

編集: - それは、特定のポストタイプのすべてのポストのリビジョンを返し

select * from wp_posts where post_type in('hg-scratch-card','revision') and post_parent in 
(
    select id from wp_posts where post_type='hg-scratch-card' 
) 
order by post_modified DESC 

: - 「HG-スクラッチカード」が、親柱は、行にありません。

+0

post_typeはpost_statusと同じようにあいまいです。エラーメッセージがあなたに伝えていたはずです。 – Strawberry

+0

質問を更新して、適切なデータサンプルと予想される結果を追加してください – scaisEdge

答えて

0
select p.id, p.post_author, p.post_date, p.post_title, p.post_content, p.post_status, p.post_modified, p.post_parent, p.post_type, 
pm.meta_key, pm.meta_value, 
u.display_name 
from wp_posts p 
inner join wp_postmeta pm on pm.post_id=p.id 
inner join wp_users u on u.id=p.post_author 
where p.post_type in('hg-scratch-card','revision') and 
p.post_parent in(select id from wp_posts where post_type='hg-scratch-card') and 
LEFT(pm.meta_key, 1)!='_' 
order by post_modified DESC 
関連する問題