It is reported that Muʿāwiyah b. Qurrah – Allāh have mercy on him – said:

Do not sit with the foolish using your knowledge, and do not sit with the knowledgeable (scholars) using your foolishness.

Al-Dhahabī, Siyar Aʿlām Al-Nubalāʾ 5:154.