Fix #4065
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 34d3a59..9c4d7e0 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1760,7 +1760,7 @@
 		}
 
 		// Convert tabs or multiple spaces into single spaces
-		$item = preg_replace('/\s+/', ' ', $item);
+		$item = preg_replace('/\s+/', ' ', trim($item));
 
 		// If the item has an alias declaration we remove it and set it aside.
 		// Note: strripos() is used in order to support spaces in table names