Because your question mentions keeping other areas of the photo out-of-focus, I assume you've considered and rejected the possibility of a smaller aperture to increase depth of field. If that is not the case, the question posted in the comments as a possible duplicate is an excellent resource.
To achieve the effect you're looking for, one option is to use a camera which allows you to tilt the lens relative to the focal plane. This can be done with most large-format cameras, a few medium-format cameras, and a few special lenses on 35mm cameras (commonly called perspective-control or tilt-shift lenses).
The principle behind their operation is the Scheimpflug Principle. Essentially, when you tilt the plane of the lens, you shift the plane of focus as it appears on your film or sensor. In the case of your example photo, a tilt to the right of the proper amount (properly, a "swing" to the right; tilts are up and down) would bring the plane of focus in line with the wall and you could achieve sharp focus along the wall even with a shallow aperture.
It's a fairly advanced topic to discuss, but it becomes intuitive when explored hands-on with the appropriate equipment.
As your original question is tagged Nikon, I assume you'd be looking for Nikon lenses. To my knowledge, Nikon offers three lenses that allow for movements:
- 24mm f/3.5 PC-E
- 45mm f/2.8 PC-E
- 85mm f/2.8 PC-E Micro
All three are excellent lenses, but not inexpensive.