Page History
...
To test the SQL Mapping, you can first create a new collection using CREATE COLLECTION and then insert data using INSERT, or you can just insert data using INSERT and a collection will be created if it does not exist. There is no direct mapping for CREATE TABLE.
Anchor | ||||
---|---|---|---|---|
|
Table of Contents |
---|
WHERE SQL Mapping
...
MongoDB | ADS MongoSQL |
---|---|
db.baseball.find( { colors: "white" } ) | SELECT * FROM baseball WHERE colors = 'white' |
db.baseball.find( { colors: { $all: [ "orange", "black" ] } } ) Note: $all selects the documents where the field holds an array and contains all specified elements. | SELECT * FROM baseball |
db.baseball.find( { colors: { $all: [ "orange", "black" ], $size: 2 } } ) Note: $size matches any array with the number of elements specified. | SELECT * FROM baseball or |
db.baseball.find( { "stats.year": { "$all": [ 2010, 2011 ] } } ) | SELECT * FROM baseball WHERE stats.year CONTAINS_ALL ( 2010, 2011 ) |
db.baseball.find( { stats: { $elemMatch: { wins: { $gt: 80 }, winPercentage: { $gt: 0.58 } } } } ) Note: $elemMatch matches more than one component within an array element. | SELECT * FROM baseball WHERE stats.wins > 80 AND stats.winPercentage > 0.58 |
Other WHERE Support
...