Создайте запрос, где класю
"Select * from s_custom_references where
article IN (SELECT ordernumber from s_articles_details where articleID = ".$articleID.") ORDER BY updated_at DESC LIMIT 5 "
Sergiu The Man