diff --git a/comment_notify.install b/comment_notify.install
index fe18281..14094b9 100644
--- a/comment_notify.install
+++ b/comment_notify.install
@@ -21,7 +21,8 @@ function comment_notify_install() {
     $comments_select->addExpression("MD5(:salt || c.mail || COALESCE(u.mail, u.init) || c.uid || c.name || c.nid || c.hostname || c.cid)", 'notify_hash', array(':salt' => $salt));
   }
   else {
-    $comments_select->addExpression("MD5(CONCAT(:salt, c.mail, COALESCE(u.mail, u.init), c.uid, c.name, c.nid, c.hostname, c.cid))", 'notify_hash', array(':salt' => $salt));
+    // Use CONCAT_WS instead of CONCAT because it can handle NULL values.
+    $comments_select->addExpression("MD5(CONCAT_WS('', :salt, c.mail, COALESCE(u.mail, u.init), c.uid, c.name, c.nid, c.hostname, c.cid))", 'notify_hash', array(':salt' => $salt));
   }
 
   // Set module weight low so that other modules act on the comment first.
