Perl JOIN-like behavior in Oracle?

I have two tables, call them PERSON and NAME.

 PERSON
  person_id
  dob

 NAME
  name_id
  person_id
  name

And say that the NAME table has data such as:

name_id  person_id  name
1        1          Joe
2        1          Fred
3        1          Sam
4        2          Jane
5        2          Kim

I need a query (Oracle 10g) that will return

name_id   names
1         Joe, Fred, Sam
2         Jane, Kim

Is there an easy way to do this?


Update:

According to the article that the fig was kind enough, starting with 9i you can do:

SELECT wmsys.wm_concat(dname) departments FROM dept;

In this example, the answer will look like this:

SELECT name_id,  wmsys.wm_concat(name) from names group by name_id
+3
source share
2 answers

You can find this article to be helpful.

+4
source

The short answer is to use the PL / SQL function. More information can be found in this post.

0
source

Source: https://habr.com/ru/post/1697238/


All Articles