Please Help Me To Convert this SQL Query Into Mongo Query

SELECT loans*, customers.id, customers.name, vendors.id, vendors.name FROM loans
LEFT JOIN customers ON customers.id = loans.customer_id AND loans.customer_type = ‘customer’
LEFT JOIN vendors ON vendors.id = loans.customer_id AND loans.customer_type = ‘vendor’
WHERE loans.loan_type = ‘issued’;

Hey @sanjoyksaha,

Welcome to the MongoDB Community :sparkles:

I will suggest you refer to the following documentation to learn more about the SQL to MongoDB mapping with the help of examples.

Also, rather than directly translating your SQL schema and queries into MongoDB, I would recommend you to consider the best data model to suit your use case which can offer better performance and less complex queries for common use cases.

Some helpful starting points for learning more about data modeling in MongoDB are:

If you do have a question about querying in MongoDB, please provide more information to help others understand your use case: → version of MongoDB server, sample documents, desired outcome, and what you have tried.

Best regards,
Kushagra