Which will be faster approach, querying one time or many times into database?

I'm a programmer and always follow the standard method to access database like getting all records at once in...