The most important thing in a sand shot is consistency. To achieve this, you need to practice a lot. No amount of theory will give you the confidence which comes with practice.
When learning the sand play, you must first aim to get out of the bunker. To do this you need to play the classic splash shot where your blade enters the sand two inches behind the ball. Do not try to vary your shot at this stage when you are still learning the shot. Hit two inches behind the ball every time until it becomes second nature to you.
Your aim should be to just get on the green. When you learn bunker play it helps not to be ambitious. The most important thing in bunker play is to get out of the bunker. You need to be absolutely consistent in this. This is absolutely necessary to achieve confidence.
Once you are able to achieve consistency, you can try variations. You can vary your swing speed to achieve different distances on your ball. The basic swing has to remain the same. The alignment of the body to the left of the target should also not be changed. You should also not try to abbreviate your follow-through in an effort to get closer to the hole. Full follow through is very important in a sand shot. Often it is a poor finish which results in the ball being left in the bunker.
Another thing to remember is never to be tentative in a sand shot. A good mental thought in a sand shot is the thought to escape the bunker. This is the first and foremost aim of the bunker shot. All other objectives must be kept subordinate to this primary objective. You need to play the shot with conviction. It is good to remember that even professionals leave the ball in the bunker when they try to play too delicately.
Once you have mastered the art of escaping the bunker you can go in for variations. This needs to be practiced first. Sometimes the variation may be necessitated by the hazards around the green-side bunker. For instance if there is a water body on the other side of the bunker it is of no use escaping the bunker only to land in the water. You need to play differently and not merely aim to get out of the bunker.
Master your basic sand shot first and then go for variations.