Concat strings of an array using N1ql

Hi Team

I have sample document as below, I would like to write a n1ql query that would return the concatenated value of all the authors in the below document.

Can I please know how to achieve that using n1ql?

"books": {
  ...
  ...
  "authors": [
    "AAAA",
    "BBBB",
   "CCCC"
  ],
  ...
  ...
}

Regards,
Venkat

https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/arrayfun.html

@maciej.tomaszewski I have gone through it already, but unfortunately I don’t see any array function supporting that.

SELECT CONCAT2(",", books.authors) FROM bucket
I don’t know your db structure but it would be sth like this. Please play with it a bit, you will figure it out :wink:

1 Like

As @maciej.tomaszewski suggested use CONCAT2() (CB 6.5.0) String Functions | Couchbase Docs.

@maciej.tomaszewski and @vsr1

Thanks for the info but unfortunately we are still not on 6.0.2 so we don’t have a CONCAT2 function available

@sri_ram ,

Follow suggestion here Array concatenate in n1ql

Thanks that worked

Regards,
Venkat