Let's look at a 1 octave D Major Scale. This is an open position scale based around the D Major Chord at the 2nd fret. Starting on the same root note as the chord (4th string open).
In this scale you have two options for the major 6th of the scale (B) it can either be played as above on the 2nd string as an open string or else you can play it on the 4th fret of the 3rd string. Because of the way the guitar is tuned this will produce the same note.
Remember to play the chord before and after playing the scale you want them to be one thing in your head so when playing a chord you know all the scale notes you can play and when improvising you know the chord tones within the scale you are using.
Buy The Book
Learn anywhere, computer, tablet or phone