Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

MongoDB C100DBA Exam - Topic 6 Question 122 Discussion

Actual exam question for MongoDB's C100DBA exam
Question #: 122
Topic #: 6
[All C100DBA Questions]

What is the equivalent command in MongoDB for the following SQL query?

SELECT * FROM posts WHERE author like "%john%"

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

0/2000 characters
Carole
25 days ago
C and D don't exist in MongoDB.
upvoted 0 times
...
Adell
1 month ago
B looks wrong. Syntax is off.
upvoted 0 times
...
Ulysses
1 month ago
I think so too. It matches the SQL.
upvoted 0 times
...
Stevie
1 month ago
A is the right choice!
upvoted 0 times
...
Georgene
2 months ago
How does regex handle case sensitivity though?
upvoted 0 times
...
Jovita
2 months ago
Definitely not B or C, those are wrong.
upvoted 0 times
...
Patria
2 months ago
Wait, is there a $like operator in MongoDB?
upvoted 0 times
...
Sommer
2 months ago
I think A is right too, looks good.
upvoted 0 times
...
Lonna
2 months ago
A is correct, regex for matching!
upvoted 0 times
...
Gabriele
2 months ago
Option A is the right choice, but I'm still wondering why they didn't use the $regex operator. Seems more straightforward to me.
upvoted 0 times
...
An
3 months ago
A) db.posts.find( { author: /John/ } ) is the way to go. Searching for a substring in the author field is easy peasy in MongoDB.
upvoted 0 times
...
Louisa
3 months ago
Option A is the winner! Gotta love that regex magic in MongoDB.
upvoted 0 times
...
Lucina
3 months ago
I agree, option A is the way to go. Searching for the author's name using a regular expression is the way to do it in MongoDB.
upvoted 0 times
...
Minna
4 months ago
A) db.posts.find( { author: /John/ } ) is the correct equivalent command in MongoDB for the given SQL query.
upvoted 0 times
...
Malcom
4 months ago
I'm leaning towards A too, but I wonder if there's a chance that B could be correct since it has a different format.
upvoted 0 times
...
Nana
4 months ago
I feel like I've seen something like this before, but I can't recall if MongoDB uses $like or not.
upvoted 0 times
...
Dulce
4 months ago
I remember practicing a similar question, and I think it was about using regex to match patterns. A seems to fit that.
upvoted 0 times
...
Louvenia
4 months ago
I think the answer might be A, but I'm not completely sure about the syntax for regex in MongoDB.
upvoted 0 times
...
Chau
4 months ago
I'm not too familiar with MongoDB, but based on my understanding of the SQL query, I think option A looks like the right translation. The regex /John/ should match any authors that have "john" anywhere in their name.
upvoted 0 times
...
Renato
5 months ago
Okay, let me think this through. The SQL query is using the LIKE operator to do a partial string match, so the MongoDB equivalent would be to use a regular expression. I'm leaning towards option A as the best fit.
upvoted 0 times
...
Lajuana
5 months ago
I'm a bit confused by the different options here. The SQL query is looking for a partial match on the author field, so I'm not sure if the /John/ regex is the right approach. Maybe option D with the $like operator would be better?
upvoted 0 times
...
Gregoria
5 months ago
Hmm, this looks like a straightforward SQL to MongoDB translation. I think I'll go with option A, it seems to match the SQL query the closest.
upvoted 0 times
Dorcas
15 days ago
Yeah, regex in MongoDB is perfect for this!
upvoted 0 times
...
Pamella
20 days ago
I agree, option A is definitely the right choice.
upvoted 0 times
...
...

Save Cancel