Use variable on Sql Select I have this query:

SELECT * 
FROM (
    SELECT @z := ticketing_ticket.id_ticket_category as id, ticketing_ticket.email,
    CONCAT(
          TIMESTAMPDIFF(day,date_create,date_close) , ' jours '
    ) AS 'temps de traitement '
    FROM ticketing_ticket 
    WHERE DATE(date_close) = CURDATE()
) AS X
CROSS JOIN (
    SELECT GROUP_CONCAT(T2.label SEPARATOR ';') AS 'Domaines', @z as id
    FROM (
        SELECT @r AS _id,
             (SELECT @r := id_parent 
              FROM ticketing_category 
              WHERE id_category = _id) AS parent_id,
              @l := @l + 1 AS lvl
        FROM ( SELECT @r :=@z , @l := 0) vars
        CROSS JOIN ticketing_category m
        WHERE @r &lt;&gt; 0
    ) T1
    JOIN ticketing_category T2
        ON T1._id = T2.id_category
) AS Y;


Output:

+----+------------------+----------+-----------------------------+----+
| ID |       EMAIL      | DURATION |           DOMAINS           | ID |
+----+------------------+----------+-----------------------------+----+
| 35 |  p.p@yopmail.com | 65 jours | Elec_Domain;Help_Sub_Domain | 38 |
+----+------------------+----------+-----------------------------+----+
| 36 | test@yopmail.com | 63 jours | Elec_Domain;Help_Sub_Domain | 38 |
+----+------------------+----------+-----------------------------+----+
| 28 |  admin@admin.com | 29 jours | Elec_Domain;Help_Sub_Domain | 38 |
+----+------------------+----------+-----------------------------+----+
| 38 |   test@test.com  | 21 jours | Elec_Domain;Help_Sub_Domain | 38 |
+----+------------------+----------+-----------------------------+----+
| 38 |   test@test.com  | 21 jours | Elec_Domain;Help_Sub_Domain | 38 |
+----+------------------+----------+-----------------------------+----+


My problem is i want to use the id on my second sub-select but on the output is the same id.
What's wrong on my request ?
The problem is that values of the UDVs is restricted to the statement an do not passed across different SELECTs and JOINs. If you want to refer to the values calculated in the one SELECT from another SELECT you have to use values stored in the resulting table from the previous statement. Try the next form of the second operand of the CROSS JOIN:

SELECT GROUP_CONCAT(T2.label SEPARATOR ';') AS 'Domaines', X.id as id
    FROM (
        SELECT @r AS _id,
             (SELECT @r := id_parent 
              FROM ticketing_category 
              WHERE id_category = _id) AS parent_id,
              @l := @l + 1 AS lvl
        FROM ( SELECT @r := X.id , @l := 0) vars
        CROSS JOIN ticketing_category m
        WHERE @r &lt;&gt; 0
    ) T1
    JOIN ticketing_category T2
        ON T1._id = T2.id_category
) AS Y;


Here I've replaced all references to the @z by X.id that contains the values of @z calculated in the first SELECT statement. 

Just to make it clear: only the last calculated value of the @z UDV is passed across the statements and then it stay unchanged. Therefore you have the same value in the last column of the resulting table. And even now I'm not sure the result would be correct because of complexity of the whole query.