5
Select * from table_name where sport_type LIKE ('Cricket','Football');

I am trying to find the documents with sport_typeof Cricket and Football using find

table.find({ sport_type : "Cricket" })

Can anyone help me to do so

2

2 Answers 2

3

Try using $or:

table.find( { $or:[ {'sport_type':'Cricket'}, {'sport_type':'Football'} ]}, 
  function(err,docs){
    // do something
});
Sign up to request clarification or add additional context in comments.

2 Comments

the equivalent of your answer is Select * from table_name where sport_type = 'Cricket' or sport_type = 'Football';. He looks for a LIKE comparison.
@Mitchapp the OP is trying to find documents with sport_type of Cricket or Football. I don't think he is looking for a pattern.
3

Maybe it's too late to answer but hopefully it will help other people.

You can use $in operator, like this:

mongoose.find({sport_type: {$in: ['Cricket', 'Football']}})

You provide an array to $in operator and it will return all the documents which have an exact sport_type in the array specified.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.