SELECT
zxc.alias1,
zxc.alias2
FROM
(SELECT p.id,
(SELECT i.column
FROM table i
WHERE i.column = p.column AND i.column <= 50
ORDER BY i.column DESC
LIMIT 1)
AS alias1,
(SELECT i.column
FROM table i
WHERE i.column = p.column AND i.column <= 50
ORDER BY i.column DESC
LIMIT 1)
AS alias2,
从表p,其中p.column=0)按zxc.column DESC作为zxc顺序
最佳答案
请试试这个零钱-
SELECT
CONCAT(zxc.id,',',zxc.status_id) AS id,
zxc.employee_name,
zxc.status,
zxc.working_days,
zxc.start_date,
zxc.status_id,
zxc.id as emp_id
FROM (
SELECT
p.id,
CONCAT(p.last_name,', ',p.first_name,' ',IFNULL(p.middle_name,'')) as employee_name,
i.start_date,
i.working_days,
i.status,
i.id as status_id
FROM employees p
INNER JOIN employees_default_shifts i ON i.employee_id = p.id AND i.start_date <= '2019-10-10'
WHERE p.is_deleted = 0
ORDER BY i.start_date DESC LIMIT 1
) as zxc
ORDER BY zxc.start_date DESC
关于mysql - 如何最小化我的查询以在navicat中缩短查询时间?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58514909/