我有以下查询:
查询1:
select column1, column2 from table1 where column1 = 12345;
结果1:
column1|column2
12345|Topics briefed:
|1) How to catch a fish
|without using a fishing rod
|2) How to cook a fish
查询2:
select column1, REPLACE(REPLACE(column2, chr(10), ''), chr(13), '') as col2 from table1 where column1 = 12345;
结果2:
column1|col2
12345|Topics briefed: 1) How to catch a fish
|without using a fishing rod 2) How to cook a fish
结果2不是我想要的,我希望所有内容都在同一行。如何获得以下结果:
column1|col2
12345|Topics briefed: 1) How to catch a fish without using a fishing rod 2) How to cook a fish
谢谢!
答案 0 :(得分:1)
也许这行得通:
select column1, REPLACE(REPLACE(REPLACE(column2, chr(10), ''), chr(13), ''), chr(09), '') as col2
from table1
where column1 = 12345;
答案 1 :(得分:1)
您没有说出如何显示这些结果,但是我的猜测是您实际上已经去除了换行符,但是用来显示它们的任何东西都将它们包裹起来。如果您使用的是sqlplus,则可以执行set linesize 999
来使行非常宽,而执行column column2 format a200
来使第二列显示200个字符的宽度。