Another interpretation of "I have seen slaves upon horses" (Ecclesiastes 10:7): It speaks of the Midianites, as it is said, "And the Midianites sold him into Egypt" (Genesis 37:36). Rabbi Abbin the Levite bar Ḥama said: The son of the bondwoman were selling, and the son of the bondman were buying. Between these and those, Joseph was sold.
Slaves on Horseback Selling and Buying Joseph into Egypt
Midrash Tanchuma Buber, Vayeshev 15:2
ד"א ראיתי עבדים על סוסים, מדבר במדינים, והמדינים מכרו אותו אל מצרים (בראשית לז לו), אמר ר' אבין הלוי בר חמא בן האמה מוכרים ובן העבד קונים, בין אלו ובין אלו נמכר יוסף.