The ring transformation of nitropyrimidinone 1 with acetophenone derivatives 2 affords two kinds of azaheterocyclic compounds, 4-phenylpyrimidines 3 and 3-nitro-6-phenyl-2-pyridones 4. On the basis of the relationship between electronic properties of the substituent and ratios of products, a plausible reaction mechanism is provided. Furthermore, the present reaction could be applied to heterocyclic ketones giving bihetaryl compounds.