DEV Community 👩‍💻👨‍💻

Tito
Tito

Posted on

MongoDB equivalent of SQL LIKE query

A quick snippet for anyone looking for equivalent SQL LIKE queries for mongodb.

db.users.find({name: /a/}) 
SELECT * FROM USERS WHERE name LIKE '%a%';

db.users.find({name: /^ja/}) 
SELECT * FROM USERS WHERE name LIKE 'ja%'

db.users.find({name: /jo$/}) 
SELECT * FROM USERS WHERE name LIKE '%jo'
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Take a look at this:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠