MySQL server has gone away SELECT id FROM ***_ecms_article_index WHERE classid='4' and id >= ((SELECT MAX(id) FROM ***_ecms_article_index where classid='4')-(SELECT MIN(id) FROM ***_ecms_article_index where classid='4')) * RAND() + (SELECT MIN(id) FROM ***_ecms_article_index where classid='4') ORDER BY id limit 6