How to declare a variable in mysql, assign it some value and use it in the request? It is necessary by means of mysql.

    1 answer 1

    User-Defined Variables

    SET @ t1 = 1, @ t2 = 2, @ t3: = 4;

    or

    SELECT @ t1, @ t2, @ t3, @ t4: = @ t1 + @ t2 + @ t3;

    Documentation

    article in Russian

    • why there is no initialization? - heff
    • happens at the first assignment, you can use cast, see examples in the dock - retvizan