Can find common principal open subsets in the intersection of two open affine subschemes Let $X$ be a scheme and let $U$ and $V$ be open affine subschemes, meaning that $(U,\mathcal{O}_X|_U) \cong (\mathrm{Spec}A, \mathcal{O}_{\mathrm{Spec}A})$ and $(V,\mathcal{O}_X|_V) \cong (\mathrm{Spec}B, \mathcal{O}_{\mathrm{Spec}B})$ for some rings $A$ and $B$. Assume that the intersection $U \cap V$ is not empty, hence it is an open subscheme of $U,V$ and $X$ (not necessarily affine). Is it possible to say that we can find principal open subsets $D(f) = \tilde{D}(g) \subseteq U \cap V$ that cover $U\cap V$ and that are both principal for $A$ (which means that $D(f) \cong \mathrm{Spec}A_f$) and at the same time for $B$ (hence $\tilde{D}(g) \cong \mathrm{Spec}B_g$)? It is certainly the case that we can do both things, but I fail to see why they can be done "simultaneously". (This argument is used, for instance, in the proof of proposition 3.2.2, page 88 of Q. Liu's "Algebraic geometry and arithmetic curves").
 A: I will post an answer for the sake of completeness, imitating the explanation referenced by MooS.
It will suffice to show that any point $p \in U \cap V$ is contained in a joint principal open subset of $U$ and $V$. Assume that we have (without loss of generality)
$$ p \in \tilde{D}(g) \subseteq D(f) \subseteq U \cap V.$$
Let $g' := g|_{D(f)}$. Then $g' \in A_f$ is equal to $\frac{h}{f^n}$ for some $h \in A$ and $n \in \mathbb{N}$. We claim that $\tilde{D}(g)=D(fh)$. Indeed,
$$D(fh)=D(f) \cap D(h) = \{x \in D(f) \mid h_x \notin \mathfrak{m}_x \} = \{x \in D(f) \mid g'_x \notin \mathfrak{m}_x \} = \tilde{D}(g).$$
Edit: Note that the assertion just proved even implies that the joint principal open subsets of $U \cap V$ form a basis for the topology on $U \cap V$. Consider a point in the non-empty intersection of two joint principal open subsets. Since the intersection is open in both $U$ and $V$, we can find principal open sets inside the intersection that contain that point. Their intersection is again open in $U$, say, so we can find a principal open $D$ of $U$ containing the point, contained in a principal open of $V$, contained in the intersection of the two joint principal opens we started with. Repeating the proof as above shows that $D$ is a joint principal open subset of $U$ and $V$.
