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:-
Filter Documents in the collection.
SQL Syntax:-
IN Operation in the collection.
SQL Syntax:-
AND Operation in the collection.
SQL Syntax:-
OR Operation in the collection.
SQL 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 DimCustomerNOSQL Syntax
db.DimCustomer.find( { } )OutPuts
SQL Syntax:-
SELECT * FROM DimCustomer WHERE CustomerID = 4NOSQL Syntax
db.DimCustomer.find( { CustomerID: 4 } )OutPuts
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
AND Operation in the collection.
SQL Syntax:-
SELECT * FROM DimCustomer WHERE CustomerName = 'Richard Thrubin' and CustomerID = 4NOSQL Syntax
db.DimCustomer.find( { CustomerName: "Richard Thrubin", CustomerID: 4 } )OutPuts
SQL Syntax:-
SELECT * FROM DimCustomer WHERE CustomerName = 'Richard Thrubin' or CustomerID = 3NOSQL Syntax
db.DimCustomer.find({ $or: [{ CustomerName: "Richard Thrubin"},{ CustomerID: 3} ] })OutPuts
NoSQL Query Syntax vs SQL Query Syntax with MongoDB
Reviewed by Pubudu Dewagama
on
10:28:00 PM
Rating:
No comments: