The cause for the pain from spicy food is often something called capsaicin (which is in chili). Other possibilities include piperine (pepper) or Isothiocyanate (wasabi and related)
Capsaicin is not soluble in water, and drinking water just spreads it through your mouth further. Instead it's soluble in fat and fat-based lotions.
The same applies to the other mentioned chemical compounds. Some are easily soluble in Ethanol (better known as alcohol).
What you want to do accordingly is drink milk, eat yogurt or similar fat-based foods to ease the pain. Alternatively you could try an alcoholic beverage, but they are effective against less kinds of "hot"