You aren't being specific enough. Some chemistries would possibly allow this but others would not. If the batteries have the same nominal voltage than theoretically they should work fine in parallel with no issues. The problem is when you start discharging them.
See the graph below:
Batteries with different capacities would discharge at different rates, so if you had two batteries in parallel of say 1000mAh and 500mAh, there would be a heavy imbalance in the rates of discharge, causing them to be at different state-of-charge percentages. If one were at 80% and another at 40% then there would be a huge issue because even though the difference in the voltages could be as small as .1v it would be enough to cause a short and cause heavy damage to your batteries. This is true for all batteries, though some like the NiMH batteries are more tolerant and could potentially survive if the currents aren't that far off. But definitely NEVER try this with a LiPo unless you are a fan of melting your hands off.
To quote SparkFun:
Be careful when connecting batteries in parallel! All the cells should have the same nominal voltage and same charge level. If there are any voltage differences, a short circuit could occur causing overheating and possibly fire.
TL;DR Hella unsafe, use at your own risk. I would not recommend.