将一个字段从表复制到同一表中的另一个字段

时间:2022-09-24 19:00:29

I used this query to copy one full column from the same table:

我使用此查询从同一表中复制一个完整列:

UPDATE 'content_type_chapter' 
   SET 'field_chapternumbersort2_value' = 'field_chapternumbersort_value'

But I have received this error.

但是我收到了这个错误。

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 ''content_type_chapter' SET 'field_chapternumbersort2_value'='field_chapternumber' at line 1

您的SQL语法有错误;检查与MySQL服务器版本对应的手册,找到正确的语法,以便在第1行使用“content_type_chapter' SET 'field_chapternumbersort2_value'='field_chapternumber'

What could be wrong, I'm unable to get it right.

可能有什么不对的地方,我做不到。

2 个解决方案

#1


7  

Just leave the quotes off your field names, otherwise it thinks you are giving it strings

只要把引号从字段名中去掉,否则它会认为你在给它字符串

#2


8  

Single-quotes are for strings.

单引号的字符串。

Try backticks instead, e.g.:

试试引号,例如:

UPDATE 
    `content_type_chapter` 
SET 
    `field_chapternumbersort2_value` = `field_chapternumbersort_value`

The backticks aren't strictly necessary, though.

不过,背勾并不是绝对必要的。

#1


7  

Just leave the quotes off your field names, otherwise it thinks you are giving it strings

只要把引号从字段名中去掉,否则它会认为你在给它字符串

#2


8  

Single-quotes are for strings.

单引号的字符串。

Try backticks instead, e.g.:

试试引号,例如:

UPDATE 
    `content_type_chapter` 
SET 
    `field_chapternumbersort2_value` = `field_chapternumbersort_value`

The backticks aren't strictly necessary, though.

不过,背勾并不是绝对必要的。