我正在尝试查询多个WordPress表格,而且我一边学习一边进行。
这是我目前的进展:
SELECT
tr.object_id,
tr.term_taxonomy_id,
p.ID,
p.post_date,
p.post_title,
p.post_excerpt,
p.guid,
t.term_id,
t.name,
tt.taxonomy
FROM
wp_116_term_relationships AS tr,
wp_116_posts AS p,
wp_116_terms AS t LEFT JOIN
wp_116_term_taxonomy as tt ON tt.term_id = t.term_id
WHERE
p.post_type = 'post'
AND p.ID = tr.object_ID
AND tr.term_taxonomy_id = tt.term_taxonomy_id
AND p.post_date > '2013-06-01'
这是我得到的内容(抱歉我无法弄清楚如何发布更清洁的内容 - 希望这样有意义)
object_id term_taxonomy_id ID post_date post_title post_excerpt guid term_id name taxonomy
2356 33 2356 2013-06-07 15:56:54 Test Post for Reports http://domain.com/?p=2356 7496 Marketing Updates category
2356 32 2356 2013-06-07 15:56:54 Test Post for Reports http://domain.com/?p=2356 470 News Updates category
2356 70 2356 2013-06-07 15:56:54 Test Post for Reports http://domain.com/?p=2356 46408 Tag Test 1 post_tag
2356 72 2356 2013-06-07 15:56:54 Test Post for Reports http://domain.com/?p=2356 46410 Tag Test 2 post_tag
2356 74 2356 2013-06-07 15:56:54 Test Post for Reports http://domain.com/?p=2356 46412 Tag Test 3 post_t
我该如何将名称字段中的数据分开,以便如果它是post_tag,则在一列(post_tag)中,如果它是类别,则在另一列(category)中?例如:
object_id term_taxonomy_id ID post_date post_title post_excerpt guid term_id post_tag category
2356 33 2356 2013-06-07 15:56:54 Test Post for Reports http://domain.com/?p=2356 7496 Marketing Updates Tag Test 1