Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copy one field from table to another field in the same table

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

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

like image 492
Nikhil Avatar asked Sep 20 '10 18:09

Nikhil


2 Answers

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.

like image 200
mechanical_meat Avatar answered Nov 20 '22 08:11

mechanical_meat


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

like image 33
Zak Avatar answered Nov 20 '22 08:11

Zak