The Prophet ﷺ said, "Whoever swears an oath and then sees that something else is better than it, let him make expiation for his oath and do what is better."
حدثنا قتيبة عن مالك بن أنس عن سهيل بن أبي صالح عن أبيه
عن النبي ﷺ قال من حلف على يمين فرأى غيرها خيرا منها فليكفر عن يمينه وليفعل
Muslim also narrated it in the Book of Oaths, in the chapter on the recommendation for one who swears an oath then sees something better than it, etc., hadith no. 1650, from the hadith of Malik through this same chain, and it is found in Muwatta 2/478 (Yahya).