Join table between Different Microservices

You’ll have to make a call to each microservice and do the join manually or pass in the relevant user ids to each service.

UserMicroservice:

SELECT * FROM Users WHERE some condition is true

Get list of Users back including their ids.

ProductMicroserivce:

SELECT * FROM Products WHERE some condition is true AND userId IN (.........)

So users and products can still be in two different databases, the products will just need to have the concept of a userId.

The reverse can also be done, ProductMicroserivce:

SELECT * FROM Products WHERE some condition is true

Extract all the UserIds then call the UserMicroservice:

SELECT * FROM Users WHERE some condition is true AND id IN (.........)

Leave a Comment