get records from A which are not in B
Options
![maverick](https://us.v-cdn.net/6037124/user_avatars/3422748.jpg)
maverick
Member ✭
Hi guys,
I have a first table "brands" which contains brands.
I have a second table "affiliations" which contains brand affiliations for each user.
I would like to create an API that allows me to retrieve the list of all brands (from the "brands" table) but for which the user is not yet affiliated (no entry present in the affiliation table for the given user).[image.png]
Ex : table "brands" :
id brands_name other fields
1 brand_ 1 xxxx
2 brand_ 2 xxxx
3 brand_ 3 xxxx
table "affiliation
user_id brand_id other fields
1 2 xxxx
in my case, I want to get the brands 1 and 3 because the user is already affiliated with brand 2.
So I made a first request to retrieve the brands for the selected user from the affiliation table.
[image.png]And a second request on "brands" table to retrieve the id's of the complete brand list:
[image.png]But, after this step, i don't understand how being able to keep just the record which exist in table "brands" but not in table "affiliation".
Any help would be much appreciate! Thx in advance
I have a first table "brands" which contains brands.
I have a second table "affiliations" which contains brand affiliations for each user.
I would like to create an API that allows me to retrieve the list of all brands (from the "brands" table) but for which the user is not yet affiliated (no entry present in the affiliation table for the given user).[image.png]
Ex : table "brands" :
id brands_name other fields
1 brand_ 1 xxxx
2 brand_ 2 xxxx
3 brand_ 3 xxxx
table "affiliation
user_id brand_id other fields
1 2 xxxx
in my case, I want to get the brands 1 and 3 because the user is already affiliated with brand 2.
So I made a first request to retrieve the brands for the selected user from the affiliation table.
[image.png]And a second request on "brands" table to retrieve the id's of the complete brand list:
[image.png]But, after this step, i don't understand how being able to keep just the record which exist in table "brands" but not in table "affiliation".
Any help would be much appreciate! Thx in advance
Comments
-
Hey Maverick, take a look at this post from a while back. I think my second comment may help. https://community.xano.com/c/transforming-data/cludq
-
Many thx ! It's working with the null condition on the second table. Perfect and in just one query !!!
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback