oracle两个表的结果如何拼接,急,求高手~

城市那么空 2013-12-27 07:52:54

求高手帮帮忙,不胜感激!!
...全文
2003 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
WSZHAO_SELECT 2014-04-14
  • 打赏
  • 举报
回复

SELECT A.ID,A.NAME||B.NAME AS NAME FROM T_A A JOIN T_B B ON A.ID=B.ID
ok
fwx515354 2014-04-12
  • 打赏
  • 举报
回复
楼主还是没把问题说明了。两表的两字段拼一块,肯定是根据什么规律或条件来拼的,如果随机拼,那做法与想法太多了。
IDowant0816 2014-04-10
  • 打赏
  • 举报
回复
引用 4 楼 zlloct 的回复:
[quote=引用 1 楼 zhangjunkui521 的回复:] 我自己写出来了,不知效率如何 select DBMS_RANDOM.RANDOM,c.id ,wmsys.wm_concat(c.name) end from ( select rownum as id, a.name from tab_a a where rownum<5 union all select rownum as id,b.name from tab_b b where rownum<5 ) c group by c.id
为什么要用GROUP BY,直接连接啊。
select t1.rn, t1.name || t2.name
  from (select rownum rn, t1.name from t1 where rownum < 5) t1,
       (select rownum rn, t2.name from t2 where rownum < 5) t2
 where t1.rn = t2.rn
[/quote] 为什么要写的这么麻烦啊 这样: select t1.no, t1.name||t2.name from t1,t2 where t1.no=t2.no;不是很简单吗
yuyeyi 2014-04-08
  • 打赏
  • 举报
回复
没有关联,直接笛卡尔积,在只用 || 链接就可以啦。
gleiyu 2014-03-11
  • 打赏
  • 举报
回复
SELECT A.ID,A.NAME||B.NAME AS NAME FROM T_A A JOIN T_B B ON A.ID=B.ID
两个表join下,合并字符串就好
北京-小北 2014-01-01
  • 打赏
  • 举报
回复
4楼的可行,
请叫我-雷人 2013-12-31
  • 打赏
  • 举报
回复
表没关联怎么连接?又或者有什么规律?
forgetsam 2013-12-31
  • 打赏
  • 举报
回复
引用 7 楼 lu010610 的回复:
[quote=引用 4 楼 zlloct 的回复:] [quote=引用 1 楼 zhangjunkui521 的回复:] 我自己写出来了,不知效率如何 select DBMS_RANDOM.RANDOM,c.id ,wmsys.wm_concat(c.name) end from ( select rownum as id, a.name from tab_a a where rownum<5 union all select rownum as id,b.name from tab_b b where rownum<5 ) c group by c.id
为什么要用GROUP BY,直接连接啊。
select t1.rn, t1.name || t2.name
  from (select rownum rn, t1.name from t1 where rownum < 5) t1,
       (select rownum rn, t2.name from t2 where rownum < 5) t2
 where t1.rn = t2.rn
[/quote]额 楼主说了 表没有关联的、[/quote] 自己查个行号当关联,多套一层而已。
_拙计 2013-12-30
  • 打赏
  • 举报
回复
引用 4 楼 zlloct 的回复:
[quote=引用 1 楼 zhangjunkui521 的回复:] 我自己写出来了,不知效率如何 select DBMS_RANDOM.RANDOM,c.id ,wmsys.wm_concat(c.name) end from ( select rownum as id, a.name from tab_a a where rownum<5 union all select rownum as id,b.name from tab_b b where rownum<5 ) c group by c.id
为什么要用GROUP BY,直接连接啊。
select t1.rn, t1.name || t2.name
  from (select rownum rn, t1.name from t1 where rownum < 5) t1,
       (select rownum rn, t2.name from t2 where rownum < 5) t2
 where t1.rn = t2.rn
[/quote]额 楼主说了 表没有关联的、
清泉灵弦 2013-12-30
  • 打赏
  • 举报
回复
select a.id,a.name||b.name name from a,b where a.id=b.id,得附加匹配条件
清泉灵弦 2013-12-30
  • 打赏
  • 举报
回复
select a.name||b.name from a,b 即可
CT_LXL 2013-12-27
  • 打赏
  • 举报
回复
引用 1 楼 zhangjunkui521 的回复:
我自己写出来了,不知效率如何 select DBMS_RANDOM.RANDOM,c.id ,wmsys.wm_concat(c.name) end from ( select rownum as id, a.name from tab_a a where rownum<5 union all select rownum as id,b.name from tab_b b where rownum<5 ) c group by c.id
为什么要用GROUP BY,直接连接啊。
select t1.rn, t1.name || t2.name
  from (select rownum rn, t1.name from t1 where rownum < 5) t1,
       (select rownum rn, t2.name from t2 where rownum < 5) t2
 where t1.rn = t2.rn
城市那么空 2013-12-27
  • 打赏
  • 举报
回复
引用 2 楼 wjk_csu 的回复:
为什么不直接合并? select a.id,a.name||b.name from tab_a a,tab_b b where a.id=b.id order by 1
我没表达明白,关键是两个表没有任何关联,要做到的就是两个表各取十条数据把两个name值拼接成一句话显示
俊凯 2013-12-27
  • 打赏
  • 举报
回复
为什么不直接合并? select a.id,a.name||b.name from tab_a a,tab_b b where a.id=b.id order by 1
城市那么空 2013-12-27
  • 打赏
  • 举报
回复
我自己写出来了,不知效率如何 select DBMS_RANDOM.RANDOM,c.id ,wmsys.wm_concat(c.name) end from ( select rownum as id, a.name from tab_a a where rownum<5 union all select rownum as id,b.name from tab_b b where rownum<5 ) c group by c.id

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧