开发者

How to convert one data type to another?

开发者 https://www.devze.com 2023-02-18 13:09 出处:网络
I have table tab1 (pseudo-structure) tab1 { fname char(20) code int } I have a procedure like this change(a varchar(20) )

I have table tab1 (pseudo-structure)

tab1
{
  fname char(20)
  code int
}

I have a procedure like this

change(a varchar(20) )
{
  update tab1
  set code = a where fname =开发者_如何学Python 'lisa'
}

I want a was every thing except int;

i want convert varchar to int and int to varchar too.


You won't need it. If you invoke it CALL change('123a31') MySQL will do its best to get a number out of your varchar.

If you absolutely need to cast try SELECT CAST('123' AS SIGNED) MySQL Docs

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号