diff --git a/apps/gallery/lib_scanner.php b/apps/gallery/lib_scanner.php
index fcd9b0acb65b7809ea4a51cd61fa45657558592b..5490c4a55adda1a77fc7996e250cce3dc1b6e8c8 100644
--- a/apps/gallery/lib_scanner.php
+++ b/apps/gallery/lib_scanner.php
@@ -42,7 +42,7 @@ class OC_GALLERY_SCANNER {
       $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE `album_id` = ? AND `file_path` = ?');
       $result = $stmt->execute(array($albumId, $img));
       if ($result->numRows() == 0) {
-        $stmt = OC_DB::prepare('INSERT OR REPLACE INTO *PREFIX*gallery_photos (`album_id`, `file_path`) VALUES (?, ?)');
+        $stmt = OC_DB::prepare('REPLACE INTO *PREFIX*gallery_photos (`album_id`, `file_path`) VALUES (?, ?)');
         $stmt->execute(array($albumId, $img));
       }
     }