Fix for SQL when DB table prefixes are used