I have pain in my left side of stomach near rib cage and blood in stool. Pain is not constant. Been happening for about two years. Somedays no pain?

See doctor. Bleeding in stool warrants an evaluation. It may be as simple as hemorrhoids, but even that needs to be treated to prevent anemia due to blood loss.
Have a healthy diet, exercise, drink plenty of water, have safe sex, and get HPV vaccine. Wish you good health!
Worrisome. You don't mention age or any other symptoms, but the fact of the matter is that this is not normal and should not have gone on this long without an evaluation with ct scan and or colonoscopy. See a specialist and hopefully you have not waited too long to do so.