Home  >  Article  >  Database  >  Oracle 将 不同列 的值 拼接成一个 字符串

Oracle 将 不同列 的值 拼接成一个 字符串

WBOY
WBOYOriginal
2016-06-07 17:29:431016browse

Oracle 将 不同列 的值 拼接成一个 字符串 --利用拼接操作符ldquo;||rdquo;或者 CONCAT(

Oracle 将 不同列 的值 拼接成一个 字符串

--利用拼接操作符“||”或者 CONCAT('','')函数,将不同列的值 拼接成一个 字符串

-- 方法一:推荐
SELECT S.TEAM ||'**'|| S.NAME ||'**'|| S.JOB_NUMBER 
FROM STAFF S WHERE S.PASS ='123456' AND S.TEAM ='南方'

--方法二:繁琐。
SELECT CONCAT(  CONCAT( CONCAT( CONCAT(S.TEAM,'**' ),S.NAME) ,'**') , S.JOB_NUMBER) 
FROM STAFF S WHERE S.PASS ='123456' AND S.TEAM ='南方'

--结果均一样如下
南方**陈某某**110320
南方**彭某某**119008
南方**黄某某**119083

 

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn