Get Started Transforming Your Data in Snowflake

In SQL, how to limit the number of rows after ordering it in Oracle DB?

  • How-Tos FAQs
  • December 16, 2018

We can perform ‘Like’ operations in MongoDB using regular expressions. In fact, regular expressions are more powerful than the Like operator. 

Let us consider the following collection:

db = {
  "fruits": [
                {"name": "apple" },
                { "name": "pineapple" },
                { "name": "orange" },
                { "name": "banana"}
              ]
}

For Like ‘%apple%’:

db.fruits.find({  name: {    $regex: "apple"  }})
#Output
apple, pineapple

For Like ‘a%’:

db.fruits.find({  name: {    $regex: "^a"  }})
#Output
apple

For Like ‘%e’:

db.fruits.find({  name: {    $regex: "e$"  }})


#Output
apple, pineapple, orange

Up Next:

Read How to convert DATETIME value to VARCHAR value in SQL server?

More Resources We Think You Might Like

SQL FAQ Feat

How to concatenate data from different rows of ...

Let us consider the following table: CREATE TABLE fruits (     ID INT,     NAME VARCHAR(50) ) INS...

  • How-Tos FAQs
  • December 16, 2018
SQL FAQ Feat

How to INSERT values in a table using SELECT qu...

This can be done in below: INSERT INTO orders (ID, customer_name, order_date, total_orders) SELEC...

  • How-Tos FAQs
  • December 16, 2018
SQL FAQ Feat

How to avoid SQL injection in PHP?

SQL injection is one of the most common vulnerabilities in a web application. We can avoid it in ...

  • How-Tos FAQs
  • December 15, 2018