If you work with traditional RDBMS and you recently come to NoSQL world you will quickly realize that most of NoSQL database vendors including
. But no worry we got you covered. We have implemented custom query parser which will do hard work for you so you don't have to spend time learning new query language for MongoDB. Our query engine will
To search text pattern you may use simple wild card (i.e. % ) in your LIKE clause or specify REGX hint. Your text pattern can end with search hints. To specify search hints use vertical bar and then one or more following options
select * from mytable where column LIKE 'some-pattern|[i][r][x][m][s]'
where options are as below
Searching for text (case-sensitive mode - this is default):
by default text pattern search is case-sensitive so no option needed.
select * from customers where password LIKE 'P@ss'
Searching for text patterns (case-insensitive mode):
by default text pattern search is case-sensitive. If you want to perform case in-sensitive search then you must provide option [i] at the end after vertical bar.
select * from customers where City LIKE 'New%|i'
Searching for text patterns using Regular Expression:
select * from customers where phone LIKE '\d\d\d|r'
Using multiple options:
select * from customers where notes LIKE '^ABC\d(.*)|rm'
-- Selecting all columns
select * from CustomerTest
-- Selecting multiple columns
select CustomerID,CompanyName from CustomerTest
-- Selecting multiple columns, where some attribute name has space in it
select CustomerID,[Contact Title] from CustomerTest
-- Using Where clause with simple condition, select all columns
select * from CustomerTest Where CustomerID='ALC3R'
-- Query ISO Date attribute
select * from Orders Where OrderDate='DATE(2015-01-31)'
-- Using ORDER BY on single column
select * from CustomerTest Order By CustomerID
-- Using muliple columns in ORDER BY
select * from CustomerTest Order By CustomerID ASC,Country DESC
-- Using CONTAINS to do substring search
select * from CustomerTest Where CustomerID CONTAINS 'C3'
-- Using LIKE to do substring search (Only % allowed as wildcard character)
select * from CustomerTest Where CustomerID LIKE '%C3%'
-- Using NOT LIKE: Return all records where CustomerID doesnt contain substring 'C3'
select * from CustomerTest Where CustomerID NOT LIKE '%C%'
-- Using LIKE to search for starts with: search all record where ContactName starts with Maria
select * from CustomerTest Where ContactName LIKE 'Maria%'
-- Limiting records returned from query using TOP clause (Similar as LIMIT found inn some RDBMS query engine)
select top 7 * from CustomerTest
-- Using IN with String Values: select all records where CustomerID is 'ALFKI' or 'BOLID' or 'C3' (String values)
select * from CustomerTest where CustomerID IN ('ALFKI', 'BOLID','C3')
-- Using IN with Numeric Values: select all records where Age is 5 or 7 (Numeric values)
select * from CustomerTest where Age IN (5,7)
-- Using OR
select * from CustomerTest Where CustomerID = 'ALFKI' OR CustomerID = 'BOLID'
-- Using OR
select * from CustomerTest Where CustomerID = 'ALFKI' OR CustomerID = 'BOLID'
-- Mixing OR / AND
select * from CustomerTest Where (CustomerID = 'ALFKI' OR CustomerID='BOLID') AND (Age =1 OR Age =2 OR Age =3)
-- Using IS NOT NULL: Get all records where Age attribute is present and set to some value other than NULL
select * from CustomerTest Where Age IS NOT NULL
-- Using IS NULL: Get all records where Age attribute is either MISSING or is set to null
select * from CustomerTest Where Age IS NULL
-- Using comparision operators
select * from CustomerTest Where CustomerID <> 'ALFKI'
select * from CustomerTest Where CustomerID != 'ALFKI'
select * from CustomerTest Where Age > 5
select * from CustomerTest Where Age >= 5
select * from CustomerTest Where Age < 5
select * from CustomerTest Where Age = 5 AND CustomerID = 'C5'
-- Using BETWEEN for range compare
select * from CustomerTest Where Age Between 5 AND 10
-- Using NOT BETWEEN for range compare
select * from CustomerTest Where Age Not Between 5 AND 10
-- Mixing conditions
select * from CustomerTest Where (Age >= 1 OR Age <= 10) AND (CustomerID ='C7' Or CustomerID ='C9' )
select * from CustomerTest Where (CustomerID = 'ALFKI' OR (CustomerID = 'BOLID' OR (CustomerID = 'C1')))