开发者

How to convert one data type to another?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜