In Spanish there are four main ways in which the subjunctive is used.
1. Formation of the negative imperative and the formal positive imperative
The exception here is no creer que
2. In subordinate clauses introduced by que
In this instance there are certain expressions and verbs which require a following subjunctive. These are:
a) After expressions which indicate possibility, such as es probable que
b) After expressions and verbs that express an emotion, such as querer or es una pena
c) After expressions and verbs that indicate necessity, influence or requests, such as es importante que or pedir
d) After verbs which indicate something is allowed or forbidden, such as dejar or prohibir
e) After verbs which involve thinking or saying BUT in the negative, such as no creer or no parecer
3. After conjunctions
The subjunctive in this case is generally used with conjunctions of time and purpose:
a) Time conjunctions-cuando, hasta que, en cuanto, mientras
BUT only use the subjunctive if the tense communicated after is in the future
ALSO if cuando is used in a question use the indicative
b) Purpose conjunctions-para que
4. In main clauses
The subjunctive is used mainly after perhaps EXCEPT for a lo mejor