Let $A,B,C \in M_n$ and the equation $AXB=C$. If either $A$ or $B$ is singular, then a solution $X$ can exist if and only if $\operatorname{rank} \left\{ B^T \otimes A \right\} = \operatorname{rank} \left\{ B^T \otimes A \operatorname{vec}(C ) \right\}$, where $\otimes$ is a Kronecker product.
Thank you so much in advance.
Hint: the key is to note that $$ (B^T \otimes A) \operatorname{vec}(X) = \operatorname{vec}(AXB) $$