when you have two notes next to each other, or on top(next to each other would be melodic beause your playing one, then the other note, but if one is above the other, then you have harmonic, because there are played at the same time) then you have a space between them from one note to the other. this is called an interval. if you play guitar/bass then you may currently think of intervals as 5 frets or 4 half steps. but actually its easer then that(well before you complicate it). the interval is just the number of notes names from one to the other(you dont count # and b unless your dealing with augmented, diminished ect). you do however always count the note that you start with. so lets do a simple one

what is the interval from A to D?(remember your alphabet ABCDEFG)

start with A and count that as one then count to D so its a 4th.

these are the intervals you can have

prime

2nd

3rd

4th

5th

6th

7th

octave

prime, 4,5,octaves are perfect. so say you went from A to D you would have a perfect 4th interval.

2,3,6,7 are Major intervals. so if you went from A to F# you have a Major 6 interval

now lets incoprerate our

major scales in here.

for now lets use the key/scale of Ab(Ab,Bb,C,Db,Eb,F,G,)

when your in scale you to find the normal intervals you must use the notes in that scale. so here we have some flates and some natural notes. if you had your first note as Ab and you wanted to go up a perfect 5th, then you would end up at Eb(not E because the E's in the Ab scale are flatted) but say you wanted to go up a Major6 interval then you would end up at F

when figuring these out, you have to take the note you want to figure the distance of and use the scale that shares that name. so say you had these

-----#O-

---------

---------

O

---------

---------

you would take the bottom note (A) and use the A scale(A,B,C#,D,E,F#,G#)

and then take the top note (F#) and see how far it is in the scale (start at A and count to F# remember to count A as one) so you have a Major7 interval there

for the example above the top note was in the scale of the bottom one. this makes it a diatonic interval(if it was not in the scale it would be a chromatic interval)

EDIT:thanks to POT for pointing out a stupid error on my part