Query condition based on relational data

Options

In the Xano-WeWeb tutorial there is an example for conditional query:
Only show records when user_id = user.ID

I also have a Company database, related to multiple users (team members) who should have access to each others records.

For instance condition for Products database should be:

Show products to users
"Where Company ID in Products = Company ID in Users"

Can you help out setup the condition?

Best Answer

  • Louis Machado - CSA
    Louis Machado - CSA Administrator

    ADMIN

    Answer ✓
    Options

    You're not using dot notation to get the value that you want inside the record. Currently, the conditional is set to be the whole record in the products_companies_id table is equal to the whole record of the user_company_id table. That's why the condition is not being met.

    You want to have something like this:

    user_company_id.company_id = products_companies_id.user_id (using dots to retrieve the value of the .company_id and .user_id columns inside those tables

Answers