This, if you have just cats and dogs. But if you have hamsters and goldfish and all other kinds of exotic pets, you would need to use some kind of dynamic query perhaps, especially if the kinds of pets are unknown in advance