Implemented match db query