Oracle SQL,连接多列+添加文本 [英] Oracle SQL, concatenate multiple columns + add text

查看:59
本文介绍了Oracle SQL,连接多列+添加文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我基本上想显示此内容(一列中的整行):

So I basically wanna display this (whole row in ONE column):

我喜欢[类型列]蛋糕和[糖霜列]和[水果列].

I like [type column] cake with [icing column] and a [fruit column].

结果应为:

Cake_Column
----------------

I like chocolate cake with whipped_cream and a cherry.

I like strawberry cake with vanilla_cream and a lemon_slice.

etc.

etc.

我需要某种TO_CHAR语句,该语句可以([[column]一些文本" [column])"new_column_name";

I need some sort of TO_CHAR statement that does ([column] "some text" [column]) "new_column_name";

我应该知道什么?

推荐答案

在Oracle中,有两个串联字符串的选项:

You have two options for concatenating strings in Oracle:

CONCAT示例:

CONCAT(
  CONCAT(
    CONCAT(
      CONCAT(
        CONCAT('I like ', t.type_desc_column), 
        ' cake with '), 
      t.icing_desc_column),
    ' and a '),
  t.fruit_desc_column)

使用||示例:

'I like ' || t.type_desc_column || ' cake with ' || t.icing_desc_column || ' and a ' || t.fruit_desc_column

这篇关于Oracle SQL,连接多列+添加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆