Example 2 Given $A=\left\{x \mid x^{2}+p x+q=0, x \in \mathrm{R}\right\}, B=\left\{x \mid x^{2}-3 x+2\right.$ $=0, x \in \mathrm{R}\}$, and $A \cap B=A$, find the values or relationship of $p$ and $q$.
Solution: From the problem, we know that $B=\left\{x \mid x^{2}-3 x+2=0\right\}=\{1,2\}$.
From $A \cap B=A$, we get $A \subseteq B$, so $A=\varnothing,\{1\},\{2\}$, or $\{1,2\}$.
When $A=\varnothing$, the equation $x^{2}+p x+q=0$ has no real roots, then $\Delta=p^{2}-4 q<0$, i.e., $p^{2}<4 q$;
When $A=\{1\}$, the equation $x^{2}+p x+q=0$ has a repeated root 1, then $p=-2, q=1$;
When $A=\{2\}$, the equation $x^{2}+p x+q=0$ has a repeated root 2, then $p=-4, q=4$;
When $A=\{1,2\}$, the equation $x^{2}+p x+q=0$ has two roots 1 and 2, then $p=$ $-3, q=2$.