Abu Umamah reported: The Prophet, peace and blessings be upon him, said, “Whoever goes to the mosque, for no reason but to learn goodness or teach others, he will have a reward like a pilgrim completing the Hajj.”
Source: al-Mu’jam al-Kabīr lil-Ṭabarānī 7473
Grade: Sahih (authentic) according to Al-Albani
عَنْ أَبِي أُمَامَةَ عَنِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَالَ مَنْ غَدَا إِلَى الْمَسْجِدِ لا يُرِيدُ إِلا أَنْ يَتَعَلَّمَ خَيْرًا أَوْ يَعْلَمَهُ كَانَ لَهُ كَأَجْرِ حَاجٍّ تَامًّا حَجَّتهُ
8/94 المعجم الكبير للطبراني
86 المحدث الألباني خلاصة حكم المحدث حسن صحيح في صحيح الترغيب