NoSQL Query Syntax vs SQL Query Syntax with MongoDB

In this post, I am going to explain how to query NoSQL table and compare both  the SQL Syntax and NoSQL syntax.
For this I am using Sudio 3T GUI application to Query the table of teh database.

Select all Documents in the collection.

SQL Syntax:-
select * from DimCustomer
NOSQL Syntax
db.DimCustomer.find( { } )
OutPuts
image
image
Filter Documents in the collection.

SQL Syntax:-
SELECT * FROM DimCustomer WHERE CustomerID = 4
NOSQL Syntax
db.DimCustomer.find( { CustomerID: 4 } )
OutPuts
image
image

IN Operation in the collection.

SQL Syntax:-
SELECT * FROM DimCustomer WHERE CustomerID  in ( 4 , 5 )
NOSQL Syntax
db.DimCustomer.find( { CustomerID: {$in :[ 4,5 ] } } )
OutPuts
image
image

AND Operation in the collection.

SQL Syntax:-
SELECT * FROM DimCustomer WHERE CustomerName = 'Richard Thrubin' and CustomerID = 4
NOSQL Syntax
db.DimCustomer.find( { CustomerName: "Richard Thrubin", CustomerID: 4 } )
OutPuts
image
image
OR Operation in the collection.

SQL Syntax:-
SELECT * FROM DimCustomer WHERE CustomerName = 'Richard Thrubin' or CustomerID = 3
NOSQL Syntax
db.DimCustomer.find({ $or: [{ CustomerName: "Richard Thrubin"},{ CustomerID: 3} ] })
OutPuts
image
image






NoSQL Query Syntax vs SQL Query Syntax with MongoDB NoSQL Query Syntax vs SQL Query Syntax with MongoDB Reviewed by Pubudu Dewagama on 10:28:00 PM Rating: 5

No comments: