如果帖子属于特定类别,我需要附加内容以发布内容。 这是我必须显示该类别中所有帖子的代码。
SELECT * FROM wp_posts
LEFT JOIN wp_term_relationships ON
(wp_posts.ID = wp_term_relationships.object_id)
LEFT JOIN wp_term_taxonomy ON
(wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
WHERE wp_posts.post_status = 'publish'
AND wp_term_taxonomy.taxonomy = 'category'
AND wp_term_taxonomy.term_id = 1
ORDER BY post_date DESC
我需要编写更新查询来附加帖子内容。这是:
UPDATE Table SET Field=CONCAT(Field,'your extra html');
如何使用select查询的结果编写更新查询?
答案 0 :(得分:0)
它可以帮到你:
UPDATE wp SET Field=CONCAT(Field,'your extra html')
WHERE wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id) AND wp_posts.post_status = 'publish'
AND wp_term_taxonomy.taxonomy = 'category'
AND wp_term_taxonomy.term_id = 1
ORDER BY post_date DESC