1

I am trying to do a bulk node update that affects 100+ nodes. I want to set each of these node's body field to a specific string. Say I want to affect all content types: "basic page".

Since my sql skills aren't up to par with join statements. I only got this far:

UPDATE field_data_body SET body_value = 'This is my string.' WHERE type = "basic_page" left join node;
3

In drupal 7 it is a bit simpler. You don't need the join.

UPDATE field_data_body
   SET body_value = 'This is my string.'
 WHERE entity_type = 'node'
   AND bundle = 'basic_page';

You must clear the drupal cache after updating content directly in the database.

Also, if you are using revisions, note that you have just changed the latest revision without creating a new revision. This may not matter to you but it's worth noting.

1
  • this works, but it doesnt work if the body field was never set for the node. it just doesnt come up in the query. Jun 20 '13 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.