Programmatically publishing and unpublishing nodes: anonymous access
Most probably caching. Directly changing something in the database is, though the fastest, not really the safest / most reliable way of doing things in Drupal.

I'd suggest to use enity_query (or in this case even direct database access) to retrieve node ids of nodes you want to update and then use 'correct' drupal way of doing things -> load all the nodes, individually change their publish status and save them.

Something along these lines...

$nodes = node_load_multiple($nids);
foreach ($nodes as $node) {
  // set status property to 1
  $node-&gt;status = 1;
  // re-save the node
  node_save($node);
}