diff --git a/modules/node/node.install b/modules/node/node.install
index fe6661c..9ffb6a9 100644
--- a/modules/node/node.install
+++ b/modules/node/node.install
@@ -573,9 +573,19 @@ function node_update_7006(&$sandbox) {
     // Get node type info, specifically the body field settings.
     $node_types = _update_7000_node_get_types();
 
-    // Create default settings for orphan nodes.
-    $extra_types = db_query('SELECT DISTINCT type FROM {node} WHERE type NOT IN (:types)', array(':types' => array_keys($node_types)))->fetchCol();
-    foreach ($extra_types as $type) {
+    // Create default settings for orphan nodes by searching the node table for
+    // any node types that don't exist.
+    $query = db_select('node', 'n');
+    $query->addField('n', 'type');
+
+    // It is possible that there are no existent node types, so only add the
+    // condition if we have at least one node type.
+    if (!empty($node_types)) {
+      $query->condition('type', array_keys($node_types), 'NOT IN');
+    }
+
+    $results = $query->execute();
+    foreach ($results->fetchField() as $type) {
       $type_object = new stdClass;
       $type_object->type = $type;
       // Always create a body. Querying node_revisions for a non-empty body
