今天记录一下在oracle中多个字段如何和合并成一个字段,使用到符号“||” 1.组合查询的数据 1)组合前查询的语句 -- 组合前数据的字段 -- select A.MID CATE_ID,A.Code CATE_CODE,A.Name CATE_NAME,A.GoodsType GOODS_TYPE_ID,B.Text GOODS_TYPE_NAME from Dxc_Goods_Cate A left join SysState B on A.GoodsType = B.Value and
同一张表存在类似多级菜单的上下级关系的数据,查询出符合条件的某些数据的id拼接成一个字段返回: SELECT CONCAT(a.pid, ',', b.subid) AS studentIDS FROM (SELECT id as pid, sourceCode as scode FROM student WHERE studentType='父级条件1' AND studentCode='父级条件2') a LEFT JOIN (SELECT id as subid, parentCode p
数据库的创建和sql语句增删改查 1. 载入驱动. 2. 连接数据库. 3. 操作数据库. 创建表: create table person( _id integer primary key, name varchar(20), age integer ); 加入: insert into person(name, age) values('lisi', 19); 删除: delete from person where _id = 1; 改动: update person set name =
列表是升序的 # -*- coding: utf-8 -*- # 合并两个排序的数组 def merge_list(a, b): if not a: return b if not b: return a a_index = b_index = 0 ret = [] while a_index < len(a) and b_index < len(b): if a[a_index] <= b[b_index]: ret.append(a[a_index]) a_index += 1 el
将多条数据组合到一行 ) set @sql='select ''roleinfo:''' ) declare cursor1 cursor for select id from Userrole where 登录名='tl' open cursor1 fetch next from cursor1 into @column begin set @sql=@sql+','+@column+'as id,(select 角色 from UserRole as s where s.id='+@colu
当使用:SELECT ','+Id FROM dbo.Test FOR XML PATH('')); //这样读取的数据虽然是1,2,3,4,但是仍然是xml格式,所以当数据超过2033时候,用sqldatereader或者sqldateadapter读取数据会截断xml文件. 此时要:SELECT STUFF((SELECT ','+Id FROM dbo.Test FOR XML PATH('')),1,1,'');//利用stuff函数将xml文件转换为一个字符串字段.就不会截断.
SELECT xq.*, ts.xu_qiu_id, ts.content FROM wx_xu_qiu xq LEFT JOIN (SELECT xu_qiu_id, GROUP_CONCAT(content) AS 'content' FROM wx_track_status GROUP BY xu_qiu_id) AS ts ON xq.id = ts.xu_qiu_id