If you’re experiencing pain, it’s common to think in either/or terms. If your knee is hurting the reaction is often to stop exercising completely. “Either I do something, or I do nothing.”
But there are many shades of gray in this scenario. You might exercise your upper body; you might exercise one leg (There is actually research showing a crossover effect from the trained side of the body to the untrained). You might modify the exercises such that the pain subsides- maybe less weight, different range of motion, or a different lifting speed(tempo).
Rarely in training or dieting is it “all or nothing.”