modifying query to allow for non-default table prefix

excluding non-default database table prefixes was an oversight that this PR resolves.