Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
bayhaqi:571Abū ʿAbdullāh al-Ḥāfiẓ > Abū Bakr Aḥmad b. Isḥāq al-Faqīh > Aḥmad b. Salamah > Isḥāq b. Ibrāhīm > Jarīr > Suhayl from his father > Abū Hurayrah

The Messenger of Allah ﷺ said: If any one of you has pain in his abdomen, but is doubtful whether or not anything has issued from him, be should not leave the mosque unless he hears a sound or perceives a smell. (Using translation from Muslim 362)   

البيهقي:٥٧١فِيمَا أَخْبَرَنَا أَبُو عَبْدِ اللهِ الْحَافِظُ أنا أَبُو بَكْرٍ أَحْمَدُ بْنُ إِسْحَاقَ الْفَقِيهُ أنا أَحْمَدُ بْنُ سَلَمَةَ نا إِسْحَاقُ بْنُ إِبْرَاهِيمَ أنا جَرِيرٌ عَنْ سُهَيْلٍ عَنْ أَبِيهِ عَنْ أَبِي هُرَيْرَةَ قَالَ

قَالَ رَسُولُ اللهِ ﷺ إِذَا وَجَدَ أَحَدُكُمْ فِي بَطْنِهِ شَيْئًا فَأَشْكَلَ عَلَيْهِ أَخَرَجَ مِنْهُ شَيْءٌ أَمْ لَا فَلَا يَخْرُجَنَّ مِنَ الْمَسْجِدِ حَتَّى يَسْمَعَ صَوْتًا أَوْ يَجِدَ رِيحًا  

رَوَاهُ مُسْلِمٌ فِي الصَّحِيحِ عَنْ زُهَيْرِ بْنِ حَرْبٍ عَنْ جَرِيرٍ

See similar narrations below:

Collected by Muslim, Suyūṭī
muslim:362Zuhayr b. Ḥarb > Jarīr > Suhayl from his father > Abū Hurayrah

The Messenger of Allah ﷺ said: If any one of you has pain in his abdomen, but is doubtful whether or not anything has issued from him, be should not leave the mosque unless he hears a sound or perceives a smell.  

مسلم:٣٦٢وَحَدَّثَنِي زُهَيْرُ بْنُ حَرْبٍ حَدَّثَنَا جَرِيرٌ عَنْ سُهَيْلٍ عَنْ أَبِيهِ عَنْ أَبِي هُرَيْرَةَ قَالَ

قَالَ رَسُولُ اللَّهِ ﷺ إِذَا وَجَدَ أَحَدُكُمْ فِي بَطْنِهِ شَيْئًا فَأَشْكَلَ عَلَيْهِ أَخَرَجَ مِنْهُ شَىْءٌ أَمْ لاَ فَلاَ يَخْرُجَنَّ مِنَ الْمَسْجِدِ حَتَّى يَسْمَعَ صَوْتًا أَوْ يَجِدَ رِيحًا  

suyuti:2735a

The Messenger of Allah ﷺ said: If any one of you has pain in his abdomen, but is doubtful whether or not anything has issued from him, be should not leave the mosque unless he hears a sound or perceives a smell. (Using translation from Muslim 362)   

السيوطي:٢٧٣٥a

"إذَا وجدَ أَحدُكُمْ في بطنِه شيئْا فأشْكَلَ عليه: أخرجَ منه شيءٌ أمْ لا؟ فلا يَخرُجنَّ من المسجدِ حتَّى يسمع صوتًا أو يجدَ ريحًا".  

[م] مسلم عن أبي هريرة