此更新/加入中的语法错误在哪里?

时间:2014-11-28 03:41:16

标签: mysql sql wordpress

UPDATE P
SET P.post_type = 'banner-slide'
FROM `berwickr_wordpress.wp_posts` AS P
INNER JOIN berwickr_wordpress.wp_term_relationships AS T
ON P.ID = T.object_id
WHERE T.term_taxonomy_id = 3

出现此错误:

 #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM berwickr_wordpress.wp_posts AS P INNER JOIN berwickr_wordpress.wp_term_rel' at line 3

snytax错误在哪里?

1 个答案:

答案 0 :(得分:1)

UPDATE不使用FROM。试试这个:

UPDATE berwickr_wordpress.wp_posts AS P
  INNER JOIN berwickr_wordpress.wp_term_relationships AS T
    ON P.ID = T.object_id
SET P.post_type = 'banner-slide'
WHERE T.term_taxonomy_id = 3

编辑:额外的OP反推(* _ *)