0

I am expecting comma added output when passed two or more static strings.

SELECT ts.NAME
FROM ...
JOIN ...

WHERE ins.FEED_NAME = 'Trend' 
....

AND ts.NAME = 'beautiful' || 'chennai'
....
AND ins.USER_ID is NULL
ORDER BY ins.CREATED_AT DESC;

How can I get the output as beautiful, chennai

Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124
Zafrullah Syed
  • 1,170
  • 2
  • 15
  • 38
  • I reopened the post as the two values passed are static and not two different rows. – Lalit Kumar B Jul 06 '15 at 11:45
  • @OP Please post a test case, i.e. create and insert statements. We don't have your tables, we don't have your data. – Lalit Kumar B Jul 06 '15 at 11:47
  • 1
    read up on the LISTAGG function. – OldProgrammer Jul 06 '15 at 11:48
  • 2
    `AND ts.NAME = 'beautiful' || 'chennai'` Are they two different rows you trying to refer to? Or, is it a single-value in the column `ts.name`? You probably mean, `ts.name IN ('beatiful', 'chennai')` in that case they are two different rows int he table, and you need `LISTAGG`. If the later is the case, then I will close it as duplicate as @a_horse_with_no_name mentioned. – Lalit Kumar B Jul 06 '15 at 11:50
  • Hello Lalit Kumar, I have the rows and I am trying to extract only those two colums data. Your comment solved my problem. I should be using ts.NAME IN. – Zafrullah Syed Jul 06 '15 at 11:57
  • @ItsZaif Ok, then just use `LISTAGG` as shown in the topic marked as duplicate. – Lalit Kumar B Jul 06 '15 at 12:04

1 Answers1

1

What you are doing is selecting records from a table where the value of the column NAME is equal to 'beautiful' || 'chennai'.

|| means string concatenation in Oracle. So effectually you are selecting NAME='beautifulchennai'.

Maybe you want to select either the value 'beautiful' or the value 'chennai'?

Then you should select NAME in ('beautiful','chennai')

Rene
  • 10,391
  • 5
  • 33
  • 46