2017-07-05 22 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'