这是wordpress数据库。它有两个表wp_terms
和wp_term_taxonomy
wp_terms has columns slug, name, term_id
wp_term_taxonomy has columns term_id, taxonomy, term_taxonomy_id.
现在我试试
UPDATE wp_terms
SET slug = CONCAT(slug,'-quotes')
FROM wp_terms, wp_term_taxonomy
WHERE wp_term_taxonomy.taxonomy = "post_tag" AND wp_term_taxonomy.term_id = wp_terms.term_id
我试图在表“wp_terms”的列“slug”的行中连接这个词,它满足某些条件。
但是mysql给出了
#1064 - 您的SQL语法出错;查看与您的MySQL服务器版本对应的手册,以便在'FROM wp_terms,wp_term_taxonomy附近使用正确的语法 wp_term_taxonomy.taxonomy =“post_tag”AN'在第3行
答案 0 :(得分:0)
FROM
不属于UPDATE
声明。如果您想加入UPDATE
中的表格,可以使用JOIN
。
UPDATE wp_terms
JOIN wp_term_taxonomy ON wp_term_taxonomy.term_id = wp_terms.term_id
SET slug = CONCAT(slug,'-quotes')
WHERE wp_term_taxonomy.taxonomy = "post_tag"
你也可以这样做:
UPDATE wp_terms, wp_term_taxonomy
SET slug = CONCAT(slug,'-quotes')
WHERE wp_term_taxonomy.taxonomy = "post_tag" AND wp_term_taxonomy.term_id = wp_terms.term_id
答案 1 :(得分:0)
试试这个:
UPDATE wp_terms
INNER JOIN wp_term_taxonomy ON wp_term_taxonomy.term_id = wp_terms.term_id
SET slug = CONCAT(slug,'-quotes')
WHERE wp_term_taxonomy.taxonomy = "post_tag"