It is narrated from Sayyiduna Abdullah bin Amr (may Allah be pleased with them both): "The Prophet (peace and blessings be upon him) entered the mosque, and there some people were remembering Allah and some people were discussing fiqh (in scholarly conversation). The Prophet (peace and blessings be upon him) said: 'Both of these gatherings are upon good. As for those who are remembering Allah Almighty and asking their Lord, if He wills He will give them, and if He wills He will withhold from them. And these people are teaching (other) people and learning themselves; and indeed I have been sent only as a teacher, and this (gathering of knowledge) is more excellent.' Then he (peace and blessings be upon him) sat down with them."
Imam Ibn Majah recorded it through al-Ifriqi, but he did not mention the words "and this is more excellent."
Al-Harith bin Muhammad bin Abi Usamah also recorded it through Muhammad bin Bakkar, from Abdullah bin al-Mubarak, from Abd al-Rahman bin Ziyad bin An'um al-Ifriqi.
I say: Al-Ifriqi is a da'if (weak) narrator. And (in the manuscript) this (narration) has been struck through, but the correct course is to retain it because of the scholarly value of the addition it contains: "this is more excellent."
Hadith Referenceإتحاف الخيرة المهرة بزوائد المسانيد العشرة / كتاب العلم / 281