TITLE: Disjoint standard open sets in Spec(R)
QUESTION [8 upvotes]: The following appeared as a homework problem last semester in Johan de Jong's algebraic geometry course at Columbia (http://www.math.columbia.edu/~dejong/schemes.html), described as "a bit of a puzzle":
Let $R$ be a commutative ring and let $P$ and $Q$ be prime ideals of $R$. Show that either one can find disjoint standard open sets $D(f), D(g) \subset Spec(R)$ such that $P \in D(f)$ and $Q \in D(g)$, or one can find a prime ideal contained in both $P$ and $Q$.
I came across this problem one day after browsing the stacks project, and hadn't seen the statement before.  I've tried a few times to prove it, without success.  Any advice? (Does the proof of this appear in any texts on algebraic geometry?)

REPLY [3 votes]: The prime ideals contained in $P \cap Q$ are the prime ideals which are disjoint to $R \setminus P \cup R \setminus Q$, which correspond to the prime ideals of $S^{-1} R$, where $S$ is the multiplicative subset of $R$ generated by $R \setminus P \cup R \setminus Q$, i.e. $S = (R \setminus P) \cdot (R \setminus Q)$. Thus, if there is no such prime ideal, we have $S^{-1} R = 0$, hence $0 \in S$, which means $fg=0$ for some $f \in R \setminus P$ and $g \in R \setminus Q$.  It follows $D(f) \cap D(g)=D(fg)=\emptyset$ and $P \in D(f)$, $Q \in D(g)$.
If conversely $P$ and $Q$ are separated by disjoint basic open subsets $D(f)$ and $D(g)$, then $fg$ is nilpotent, say $f^n g^n = 0$. But then $P$ and $Q$ are also separated by the disjoint basic open subsets $D(f^n)$ and $D(g^n)$, so that we may run the argument above backwards.
Remark: From this observation it follows easily that the spectrum of a zero-dimensional ring is Hausdorff.