Let $f,g:A \to B$ be two ring homomorphisms of noetherian rings satisfying that for any prime ideal $\mathfrak{q} \subset B$, $f^{-1}(\mathfrak{q})=g^{-1}(\mathfrak{q})=:\mathfrak{p}$ and the induced morphisms from $A/\mathfrak{p} \to B/\mathfrak{q}$ are the same. Is it true that $f=g$? If not true in general, is there any known additional conditions on $A$ or $B$, for which we have a positive answer to the question?
Any reference/hint will be most welcome.