mysql - 如何在Sql数据库中的varchar中添加+符号

标签 mysql

Declare @mobile varchar(20)
If @mobile like '971%'
Begin
Set @mobile='+'+@mobile
End

如果我将手机号码传递为 9715628...

我应该得到的结果为+9715628...

最佳答案

使用CONCAT

Set @mobile=CONCAT('+', @mobile);
MySQL中的

+表示算术加法运算。

您不能使用 + 在 MySQL 中连接字符串。

关于mysql - 如何在Sql数据库中的varchar中添加+符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39061188/

相关文章:

mysql - mysql 子查询中的 where 子句之外

php - 无法发送内容类型 : text/xml header from PHP at the same time getting the data from MYSQL

mysql - WordPress/Digital Ocean mysql 密码重置(困难场景)我被难住了

mysql - 如何从MySQl中的联合表中过滤掉一个值?

mysql - 交集表或通用 super 表

mysql - MariaDB语法的一些问题

mysql - MySQL 的最佳 bool 值是多少?

php - 更新查询 INNER JOIN mysqli

mysql - MySQL Workbench 中的 MySQL WITH ROLLUP 查询语法错误?

mysql - 使用 Active Record 区分大小写的数据库搜索