- Query all
Sql:select * FROM table_name
Mongodb:db.getCollection (' Journal paper '). Find ({})
As shown, get all the data under the journal paper Collection
Conditional query
Note: Please note that the data type of the selected column
1. Journal _title = ' Nature '
Sql:select * FROM table_name where journal_title = ' Nature '
Mongodb:db.getCollection (' Journal paper '). Find ({"Journal_title": "Nature"})
2. volume<495:
Sql:select * FROM table_name where volume< 495;
Mongodb:db.getCollection (' Journal paper '). Find ({"Volume": { $lt:"495"}). Pretty ()
3. Volume <= 495
Sql:select * FROM table_name where volume<= 495;
Mongodb:db.getCollection (' Journal paper '). Find ({"volume": { $lte : " 495 "}}). Pretty ()
4. Volume >495
Sql:select * FROM table_name where volume> 495;
Mongodb:db.getCollection (' Journal paper '). Find ({"volume": { $gt : "495 "}}). Pretty ()
5. Volume!=495
Sql:select * FROM table_name where volume! = 495;
Mongodb:db.getCollection (' Journal paper '). Find ({"volume": { $ne : "495"}} ). Pretty () and, or query
6. And query:
Sql:select * FROM table_name where journal_title = ' Nature ' and vulome> 495;
Mongodb:db.getCollection (' Journal paper '). Find ({"Journal_title": "Nature" Volume: { $gt : "495"}}). Pretty ()
7. or query:
Sql:select * FROM table_name where journal_title = ' Nature ' or vulome> 495;
Mongodb:db.getCollection (' Journal paper '). Find ({$or: [{"Journal_title": "Nature"} ,{ "volume": { $GT : "495"}]}). Pretty ()
8. And and or union query:
Sql:select * FROM table_name where volume>52 and Journ Al_title = ' Nature ' or journal_title = ' Meccanica ';
Mongodb:db.getCollection (' Journal paper '). Find ({"volume": {$gt: ' '}, $or: [{"Journal_title": "Nature"},{"Journal_title ":" Meccanica "}]}). Pretty ()
MongoDB Query Collation