You need to make a call for each microservice and make a connection manually or pass the corresponding user IDs to each service.
UserMicroservice:
SELECT * FROM Users WHERE some condition is true
Get a list of users, including their id s.
ProductMicroserivce:
SELECT * FROM Products WHERE some condition is true AND userId IN (.........)
Thus, users and products can still be in two different databases, products just have to have a userId concept.
You can also do the opposite, ProductMicroserivce:
SELECT * FROM Products WHERE some condition is true
Extract all UserIds, then call UserMicroservice:
SELECT * FROM Users WHERE some condition is true AND id IN (.........)
source share