sub QUEERY

oren levy shared this question 6 years ago
Answered

How can I execute sql such SELECT * FROM <table2> WHERE <field1> IN(SELECT <field2> FROM <table2>)

Replies (1)

photo
1

NoSQLBooster 4.x currently does not support subqueries and SQL JOIN. We plan to provide SQL JOIN and subquery-like functionality in the next major upgrade.

photo
1

tnx

im waiting

photo
1

+1

Is it possible to do without SQL?

photo
1

Yes, you can do it without SQL. MongoDB 3.2+ have supported left-join like aggregation oprerator. The $lookup stage performs a left outer join to an unsharded collection in the same database to filter in documents from the “joined” collection for processing.

More about $lookup, please refer to : https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/

e.g. (NoSQLBooster fluid aggregate API)

db.orders.aggregate()
      .lookup({
            from: "warehouses",
            localField: "item",
            foreignField: "stock_item",
            as: "warehouses"
      })

photo
Leave a Comment
 
Attach a file