create table k_user (
op_id VARCHAR(36) not null,
op_name VARCHAR(100) not null,
password VARCHAR(100) not null,
real_name VARCHAR(100) not null,
lock_mark VARCHAR(50) not null,
dept_no TEXT null,
post_id TEXT null,
tel VARCHAR(30) null,
mail VARCHAR(50) null,
create_id VARCHAR(36) not null,
create_name VARCHAR(100) not null,
create_time VARCHAR(17) not null,
modify_id VARCHAR(36) null,
modify_name VARCHAR(100) null,
modify_time VARCHAR(17) null,
remark VARCHAR(1024) null,
constraint PK_K_USER primary key (op_id)
);
create table k_user_role (
user_id VARCHAR(36) not null,
role_id VARCHAR(36) not null,
constraint PK_K_USER_ROLE primary key (user_id, role_id)
);
create table k_role (
op_id VARCHAR(36) not null,
op_name VARCHAR(100) not null,
create_id VARCHAR(36) not null,
create_name VARCHAR(100) not null,
create_time VARCHAR(17) not null,
modify_id VARCHAR(36) null,
modify_name VARCHAR(100) null,
modify_time VARCHAR(17) null,
remark VARCHAR(1024) null,
constraint PK_K_ROLE primary key (op_id)
);

select * from (select u.*,     array_to_string ( ARRAY ( SELECT  role_id FROM k_user_role ur WHERE ur.user_id = u.op_id ),',' ) AS user_role,     array_to_string ( ARRAY ( SELECT  op_name FROM k_user_role ur,k_role r WHERE ur.role_id=r.op_id and ur.user_id = u.op_id ),',' ) AS role_name FROM  k_user u ) k_user  limit 15 offset 0

postgresql 行转列,拼接字符串的更多相关文章

  1. 行变列 拼接字符串 MSSQL 一个超级搞的问题

    由数据 ThreeLevelSortID KeyWordID KeyWordName key1 key2 key3 key4 得到数据大 ThreeLevelSortID KeyWordName ke ...

  2. sqlserver 行转列、字符串行转列、自动生产行转列脚本

    行转列,老生常谈的问题.这里总结一下网上的方法. 1.生成测试数据: CREATE TABLE human( name ), --姓名 norm ), --指标 score INT , --分数 gr ...

  3. postgresql行转列

    问:怎么分页&&按条件&&按顺序&&姓名不重复查出数据? 答:其实就是行转列,那么,postgresql怎么进行转列呢,百度了下,大概有三种写法 写法1 ...

  4. SQl 分组后按照某一列拼接字符串

    /* 分组之后拼接字符串 */ ;with t as( SELECT WorkflowId,Remark FROM dbo.OperatorAutomationProcess GROUP BY Wor ...

  5. Oracle中用一条Sql实现任意的行转列拼接 多行拼接

    表结构和数据如下(表名Test): NO VALUE NAME 1 a 测试1 1 b 测试2 1 c 测试3 1 d 测试4 2 e 测试5 4 f 测试6 4 g 测试7 Sql语句: selec ...

  6. postgresql 行转列,列转行后加入到一个整体数据

    这里行转列的基本思想就是使用max,因为其他列下面都是NULL,所以可以Max最后就只能得到有值的这行 普通的查询: SELECT icd , case when (ROW_NUMBER() OVER ...

  7. postgresql行转列并拼接字符串

    有这样一张表: ; id |   kw   ----+--------  1 | big  1 | hello  2 | oracle  2 | small  2 | apple  3 | shit( ...

  8. 中等难度SQL语句(存储过程,分页,拼接字段、游标,日期类型转换,动态行转列,视图)汇总

    一.创建存储过程 if Exists(select name from sysobjects where NAME = 'sp1LoginUser' and type='P')drop procedu ...

  9. Mysql数据处理/行转列/列转行/分割/拼接/数据复制汇总

    mysql数据处理记录(使用的 Workbench) 生成随机数 逗号或分号拼接的字符串分割成多行 多行数据转化成用逗号拼接的字符串 将A表的数据添加到B表 一.生成随机数 生成18位:(19位就加颗 ...

随机推荐

  1. Oracle “CONNECT BY” 使用

    Oracle “CONNECT BY” 使用 功能说明: 语法结构如下: [ START WITH condition ] CONNECT BY [ NOCYCLE ] condition 说明: 1 ...

  2. 子查询优化成join关联查询时要注意一对多关系

    mysql> select * from t where t.id in (select t1.tid from t1); +------+ | id | +------+ | +------+ ...

  3. EXTJS 4.2 资料 控件之checkboxgroup的用法(静态数据)

    1.页面 1.1点击‘横幅’,需要动态显示隐藏文本框 { xtype: 'fieldset', title: '指定附加图&横幅设置', collapsible: true, items: [ ...

  4. 【BZOJ2199】 [Usaco2011 Jan]奶牛议会

    Description 由于对Farmer John的领导感到极其不悦,奶牛们退出了农场,组建了奶牛议会.议会以“每头牛 都可以获得自己想要的”为原则,建立了下面的投票系统: M只到场的奶牛 (1 & ...

  5. kissy使用注意事项

    使用kissy注意: 下载kissy压缩包后只需要拷贝build包到项目中即可, 样式自己写不用引用. 1.4.x引这个文件seed-min.js1.3.x引kissy-min.js

  6. 一种高斯模糊渐变动画的实现-b

    关于高斯模糊的方式有很多种,但是如果需要模糊渐变,那么对这种高斯模糊算法的性能要求是比较高的,今天这里重点不讨论算法,只是提供一个动画实现的思路.动画效果如下: 高斯模糊渐变动画 //高斯模糊 -(U ...

  7. Linux Mint SmoothTask2的安装方法

    首先,先下载smooth task:点击这里下载 下载之后解压缩,里面有个install文件,点击打开: To install plasmoid unpack archive, go to the d ...

  8. 使用Yeoman搭建 AngularJS 应用 (6) —— 让我们搭建一个网页应用

    原文地址:http://yeoman.io/codelab/review-generated-files.html 打开mytodo文件夹,你会看到现在的基架.如下图所示 在mytodo文件夹,我们能 ...

  9. linux 命令 备忘

    openssl rand -base64 32 随机数 date | md5sum data 日期 cal 日历 man -f man sync 数据同步写入磁盘 shutdown reboot ha ...

  10. Side-by-side assembly

    Side-by-side technology is a standard for executable files in Windows 98 Second Edition, Windows 200 ...