can’t have your cake and eat it too
You cannot enjoy two mutually exclusive benefits at the same time; you must choose between incompatible options.
Learn English idioms with meanings and examples