Get the type of a variable in MySQL

后端 未结 3 1536
感情败类
感情败类 2021-01-01 22:32

If I define a variable like set @a = \"1\";. How can I see that @a is a string?

3条回答
  •  离开以前
    2021-01-01 23:10

    You cannot determine the type of a variable in MySQL.

    As an alternative, you can easily CAST() your variable in the type you desire:

    @a = CAST(123 AS CHAR);
    

    More information and examples about casting in the MySQL Manual:

    11.9. Cast Functions and Operators

提交回复
热议问题