database query modified for database attributes

database query modified for database attributes
which solves variations in different database query.