In oracle I can:
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
Is there any command in mongodb like this?
Yes, with the aggregation framework you can run a pipeline that uses the $out operator as means to write the results of the query to another collection.
Consider running the following aggregate operation:
db.tbl_temp1.aggregate([
{ "$match": { "fld_order_id": { "$gt": 100 } } },
{ "$project": { "fld_id": "$fld_order_id" } },
{ "$out": "tbl_temp2" }
])
In the above aggregation, the $match pipeline step acts as a filter on the document stream to allow only matching documents to pass unmodified into the next pipeline stage:
{ "$match": { "fld_order_id": { "$gt": 100 } } },
and is equivalent to the SQL's WHERE clause
WHERE tbl_temp1.fld_order_id > 100
The next $project pipeline stage selects/reshapes each document in the stream, such as adding new fields or removing existing fields:
{ "$project": { "fld_id": "$fld_order_id" } },
is the same as
SELECT tbl_temp1.fld_order_id AS fld_id
and the final $out operator stage
{ "$out": "tbl_temp2" }
writes the resulting documents of the aggregation pipeline to a collection, akin to
INSERT INTO tbl_temp2