Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
SELECT * FROM `table_orders` WHERE `user_id` = 1 ORDER BY `order_id` DESC LIMIT 2;
SELECT * FROM `table_orders` WHERE `user_id` IN (1, 3, 4) ORDER BY `order_id` DESC MAGIC_LIMIT 2;
SELECT a.* FROM `table_orders` a WHERE a.`user_id` IN (1, 3, 4) INNER JOIN (SELECT * FROM `table_orders` WHERE `user_id` = a.`user_id` ORDER BY `order_id` DESC LIMIT 2) b ON b.user_id=a.user_id and b.order_id=a.order_id