Suppose $X$ is an arbitrary scheme and $U \cong \operatorname{Spec} A$ and $V \cong \operatorname{Spec} B$ are affine upon subsets of $X$. It's not true in general that $U \cap V$ is affine, so if we want to prove basic results about general schemes (e.g. the stuff in section II.3 of Hartshorne), we need some technical means of understanding what goes on on the intersections of open affines.

I've heard that this can be done by covering $U \cap V$ with open sets which are distinguished in both $U$ and $V$, i.e. sets $W \subseteq U \cap V$ with $W \cong \operatorname{Spec} A_f \cong \operatorname{Spec} B_g$ for some $f \in A$ and $g \in B$. I'm having trouble actually proving this.

So, questions:

Is this actually true?

If so, how are these sets constructed?