2017-07-05 32 views
-1

我试图通过数据库/ phpmyadmin更新我网站上的很多帖子。数据库更改不工作

**我的使命: 我想取消发布一系列具有特定catergory(term)的帖子。 帖子和术语在数据库中有自己的列。 **

我已经进入这个SQL查询:

Update posts 
SET posts.post_status = 'draft' 
WHERE terms.term_id = 4 and posts.post_type ='post' 

这应该工作,但是我得到这个消息: 1054 - 在where子句(terms.term_id)未知列。

这非常奇怪,因为phpmyadmin在输入查询时建议使用此列。任何想法如何解决这个问题?

enter image description here

+2

你没有指定什么'terms'是 –

+0

是否有对'posts'表'term_id'? –

+0

你的查询绝对没有意义......你正在更新一个帖子表,基于与帖子表没有任何关系的条款陈述。我建议你阅读一些关于mysql的基本教程。 –

回答

0

我不得不添加在查询中的插图中的表:

Update posts 
INNER JOIN terms, term_relationships, term_taxonomy 
SET posts.post_status = 'draft' 
WHERE terms.term_id = 4 and posts.post_type ='post'