Skip to content
Advertisement

How to minimize my query to fast the query time in my navicat?

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,

FROM table p WHERE p.column = 0 ) as zxc ORDER BY zxc.column DESC

Advertisement

Answer

Please try this change-

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
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement