The Messenger of Allah ﷺ said, "Whoever takes an oath and then sees that something else is better than it, let him make expiation for his oath and do what is better."
أن رسول الله ﷺ قال: من حلف بيمين، فرأى غيرها خيرا منها، فليكفر عن يمينه، وليفعل الذي هو خير.
Malik narrated it in the Book of Vows and Oaths (11) from Suhayl bin Abu Salih, from his father, from Abu Hurairah, as mentioned. Muslim also narrated it in the Book of Oaths and Vows (12:1650) through the route of Malik, with the same wording.