Matching values from multiple arrays

Options
Gi Ma
Gi Ma Member
edited November 2022 in ? Transforming data

Hi there,

I have the following set-up:

----

Database table: users

  • userID
  • name
  • companyID

------

Database table: messages

  • messageID
  • target_users (which is an array() that simply contains userID's)

------

Array companies: which is just a list of companyID's


Now what I want to do is the following:

A query that says:

SELECT FROM messages WHERE target_users [CONTAINS ANY USERS THAT HAS OWNER any company within my list of companies]


Noteworthy: I might have multiple users under this company, and obviously multiple companys. And, multiple messages that can apply.


I'm not sure if I'm expressing myself clearly. What I want to do is: I have two arrays, and via a Query I need to match all the hits in between these two arrays. I tried around a little with left joins but I'm not too experienced with PostgreSQL and Xano's set-up around it.

Answers