快捷搜索:  汽车  科技

数据库连接字符串的内容(数据库中的字符串拼接)

数据库连接字符串的内容(数据库中的字符串拼接)3.MySQL中,使用concat函数拼接字符串: select 'hello' 'sql' 'SQLSERVER';输出结果均为:hellosqlSQLSERVER select 'hello'||'sql'||'oracle' from dual; 输出结果为:hellosqloracle2. SQL Server中,使用“ ”或concat 函数(SQLServer 2012 新增) 实现字符串拼接: select concat('hello' 'sql' 'SQLSERVER'); 或

日常工作中,时常需要将两个或多个字符串拼接在一起,组合成一个新的字符串。而字符串拼接地实现在各个关系型数据库中略有差异。

1.Oracle中,使用 “||”拼接符或concat函数实现字符串拼接:

select concat('hello' 'oracle') from dual;

输出结果为:hellooracle

在Oracle中concat函数只能拼接两个字符串,如果想拼接两个以上的字符串可以使用 “||”拼接符:

select 'hello'||'sql'||'oracle' from dual;

输出结果为:hellosqloracle

2. SQL Server中,使用“ ”或concat 函数(SQLServer 2012 新增) 实现字符串拼接:

select concat('hello' 'sql' 'SQLSERVER');

select 'hello' 'sql' 'SQLSERVER';

输出结果均为:hellosqlSQLSERVER

3.MySQL中,使用concat函数拼接字符串:

select concat('hello' 'sql' 'Mysql');

输出结果为:hellosqlMysql

4.PostGreSQL中 使用 “||” 或concat函数实现字符串拼接:

select concat('hello' 'sql' 'PostgreSQL');

select 'hello'||'sql'||'PostgreSQL';

输出结果为: hellosqlPostgreSQL。

数据库连接字符串的内容(数据库中的字符串拼接)(1)

查询输出结果

猜您喜欢: