Sahl bin Saad reported,

The Messenger of Allah ﷺ said, "Whoever enters this mosque of mine to learn something good or to teach it is like a warrior striving in the path of Allah Almighty, and whoever enters it for any other purpose is like one who sees something that pleases him while it belongs to someone else."

Azami 1114

Hasan

عن سهل بن سعد، قال

قال رسول الله ﷺ: من دخل مسجدي هذا يتعلم خيرا، أو يعلمه كان كالمجاهد في سبيل الله تعالى، ومن دخله لغير ذلك كان كمنزلة الذي يرى الشيء يعجبه وهو لغيره.

الأعظمي 1114حسن
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Knowledge
Chapter
Encouragement to seek knowledge
Section
Virtue of one who goes out seeking knowledge
Numbering
Jami al-Kamil 1114 (2nd edition)
Azami 1114