The subjunctive is usually used in dependent clauses introduced by que or another subordinating conjunction, but not all que-clauses take the subjunctive. All of these clauses fulfill one of two conditions: they either describe a potential or hypothetical situation, or else they reflect the subject's subjective or emotional reaction to a situation. Usually the main clause contains elements which condition the choice of the subjunctive.
The three most common types of dependent clauses in Spanish are noun clauses, adjectival clauses, and adverbial clauses.
Noun clauses (view lesson here)
A noun clause is one which functions as a noun, normally as the direct object or the subject of a verb. It is usually introduced by the conjunction que (that).
Quiero que venga a cenar con nosotros.
I want him to come dine with us.
Adjectival clauses (view lesson here)
Adjectival clauses function as adjectives modifying a noun or pronoun, which is known as the antecedent (antecedente). These clauses are most frequently introduced by the relative pronouns que (which/that/who) quien/quienes (who), el que, la que, los que, los que (which/that/who), or el/la cual, los/las cuales (which/that/who).
If the noun or pronoun modified is negated, nonexistent or indefinite, then the verb in the modifying clause will be in the subjunctive.
Estoy buscando una secretaria que hable español.
I am looking for a secretary who speaks Spanish.
Adverbial clauses (view lesson here)
Adverbial clauses are introduced by conjunctions, such as para que (so that), antes de que (before), and hasta que (until). The indicative or subjunctive mood may be required in the adverbial clause depending on various factors.
If no change of subject is involved and if the adverbial expression deals with something that is viewed as completed, habitual, or factual, the indicative is used. If the situation in the adverbial clause is viewed as something hypothetical or anticipated —rather than completed, habitual, or factual— then the subjunctive is required.
Nosotros no saldremos hasta que limpiemos la casa.
We won't leave until we clean the house.