Let M be a metric space and D a finite set of positive integers. A subset C ⊆ M is called a D-distance code if the distance between any two distinct elements of C takes values only in D Few-distance codes have been extensively studied in various metric spaces. In this work,we focus on few-distance codes in Hamming space,leveraging the Deza–Erdos–Frankl theorem as our primary tool. This theorem provides an exact bound for uniform families with restricted intersection sizes,resolving the binary case in Johnson space. We extend this result to the q-ary case,deriving a q- analogue of the Deza–Erdos–Frankl theorem.Remarkably, the upper bound for few-distance codes in q-ary Johnson space matches that of the binary case and is independent of q, the alphabet size. We then apply this resplt to address several problems concerning few- distance codes in Hamming space.