We can draw a rough diagram to solve this problem:
Q is between P and R.
The total length, PR, is 42.
Now,
PR is broken down into 5 + 2 = 7 "parts"
So, each "part" is 42/7 = 6 units
PQ = 5 "parts" = 5 * 6 units = 30 units
QR = 2 "parts" = 2 * 6 units = 12 units
Thus,
PQ = 30QR = 12