现在的位置: 网页制作教程网站制作教程 >正文
SQL语句教程

sql语句中字符串如何连接

发表于2017/2/23 网站制作教程 0条评论 ⁄ 热度 2,081℃

在sql语句中,字符串如何连接或者叫拼接。我们以sqlserver,oracle,mysql三种数据库为例,以实例讲解在SQL语句中进行字符串拼接的方法。

sqlserver:

select '123'+'456' from table;

oracle:

select '123'||'456' from table;
//或
select concat('123','456') from table;

mysql:

select concat('123','456');

注意:SQL Server 2012及往后版本已新增concat函数。oracle和mysql中虽然都有concat,但是oracle中只能拼接2个字符串,所以建议用||的方式,mysql中的concat则可以拼接多个字符串。

  • 暂无评论