Quantcast
Channel: CodeFari
Viewing all articles
Browse latest Browse all 265

Like in MongoDB Query

$
0
0
In SQL, 'LIKE' query look like as below

SELECT*FROM[dbo.][USERS]WHEREFNAMELIKE'%DILIP%'

In MongoDB it's look like as below(query in MongoDB console)

db.USERS.find({"FNAME":/DILIP/})

Same as

db.USERS.find({"FNAME":/^DILIP/})   // FNAMELIKE'DILIP%'

db.USERS.find({"FNAME":/DILIP$/})   // FNAMELIKE'%DILIP'

$regex in MongoDB

Viewing all articles
Browse latest Browse all 265

Trending Articles