Skip to content
Advertisement

Accessing array elements in query postgres

I’m currently building a query to retrieve some data from my db, I need to access the documents stored in an array, this is how the table crm_company looks:

I have another table for users by document crm_user which looks like this:

What I want as a final result is:

I just have tried somehing like the following:

But I’m still unable to retrieve the documents from array.

Thanks in advance for any hint or help.

Advertisement

Answer

If it’s too late to follow the advice in the comment of Laurenz Albe then do this:

  1. Use a query (or create a view) to have the list of company documents normalized

  2. Access documents’ details in other tables by document_id using join

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement