N-Boc-4-Hydroxypiperidine (I) was converted to the mesylate (II) with methanesulfonyl chloride and pyridine. Then, alkylation of 3-methyl-4-phenylpyrazole (III) with (II) in the presence of NaH yielded a mixture of regioisomeric pyrazoles (IV) and (V), which were separated using flash chromatography. The required isomer (IV) was subsequently treated with HCl in Et2O to remove the Boc protecting group. The resulting piperidine (VI) was finally alkylated with 3-(bromomethyl)benzonitrile (VII) to afford the title compound.