SELECT o.datestart, o.time, cl.fio, clt.type, s.servicename, o.id as order_id, o.orderstatusid,
o.paymentid, oget.name as getname , odo.name as doname FROM cs_orders o, cs_client cl,
cs_clientstypes clt, cs_service s, operators odo, operators oget
WHERE o.idEKB=cl.idpromin AND clt.id=cl.prioritet AND s.id=o.serviceid
AND oget.login=o.loginget AND odo.login=o.logindo
AND CONCAT(o.datestart,' ',o.time) BETWEEN '2020-05-13 00:00:00' AND '2020-05-13 16:38:00'
ORDER BY order_id DESC LIMIT 20;
SELECT `o`.`datestart`, `o`.`time`, `cl`.`fio`, `clt`.`type`, `s`.`servicename`,
`o`.`id` as `order_id`, `o`.`orderstatusid`, `o`.`paymentid`,
`oget`.`name` as `getname` , `odo`.`name` as `doname`
FROM (
SELECT `datestart`, `time`, `id`, `orderstatusid`, `paymentid`
FROM `cs_orders`
WHERE CONCAT(o.datestart,' ',o.time)
BETWEEN '2020-05-13 00:00:00' AND '2020-05-13 16:38:00'
) AS `o`
JOIN `cs_client` AS `cl` ON `cl`.`idpromin` = `o`.`idEKB`
JOIN `cs_clientstypes` AS `clt` ON `clt`.`id` = `cl`.`prioritet`
JOIN `cs_service` AS `s` ON `s`.`id` = `o`.`serviceid`
JOIN `operators` AS `odo` ON `odo`.`login` = `o`.`logindo`
JOIN `operators` AS `oget` ON `oget`.`login` = `o`.`loginget`
ORDER BY `order_id` DESC
LIMIT 20