diff --git a/paymentreference/paymentreference.install b/paymentreference/paymentreference.install
index d7a03c8..54cfab4 100644
--- a/paymentreference/paymentreference.install
+++ b/paymentreference/paymentreference.install
@@ -84,7 +84,9 @@ function paymentreference_field_schema($field) {
  */
 function paymentreference_update_7100(&$sandbox) {
   $pids = db_query("SELECT pr.pid FROM {paymentreference} pr LEFT JOIN {payment} p ON pr.pid = p.pid WHERE p.pid IS NULL")->fetchCol();
-  db_delete('paymentreference')
-    ->condition('pid', $pids)
-    ->execute();
+  if ($pids) {
+    db_delete('paymentreference')
+      ->condition('pid', $pids)
+      ->execute();
+  }
 }
\ No newline at end of file
