select * from 
(
SELECT
    desks_sub.desk_id AS desk_id,
    {user_id} AS user_id,
    {parent_desk} AS parent_desk,
    desks_sub.desk_code AS desk_code,
    desks_sub.import_open AS import_open,
    desks_sub.type_desk AS type_desk,
    ifnull(desks_DesksImport_open.countDesksImport_open, 0) AS DesksImport_open,
    ifnull(desks_CardsImport_open.countCardsImport_open, 0) AS CardsImport_open
FROM
    (select * from desks_data_base where import_open and user_id = {user_id} and parent_desk = {parent_desk}) desks_sub
    LEFT JOIN (
        -- desks_Import_open
        SELECT
            desks.parent_desk AS desk_id,
            COUNT(desks.desk_id) AS countDesksImport_open
        FROM
            desks
        where
            import_open 
        GROUP BY
            desks.parent_desk
    ) desks_DesksImport_open ON desks_sub.desk_id = desks_DesksImport_open.desk_id
    LEFT JOIN (
        -- Cardsimport_open
        SELECT
            desks_sub.desk_id AS desk_id,
            COUNT(cardsImport_open.card_id) AS countCardsImport_open
        FROM
            (select * from desks where import_open and user_id = {user_id} and parent_desk = {parent_desk}) desks_sub
            JOIN (
                SELECT
                    card_id,
                    tree,
                    user_id
                FROM
                    cards_data_base
                WHERE
                    import_open and user_id = 1
            ) cardsImport_open ON desks_sub.user_id = cardsImport_open.user_id
        WHERE
            cardsImport_open.tree LIKE CONCAT('%', desks_sub.desk_id, '%')
        GROUP BY
            desks_sub.desk_id
    ) desks_CardsImport_open ON desks_sub.desk_id = desks_CardsImport_open.desk_id) desk_data_import