> For the complete documentation index, see [llms.txt](https://janeto.gitbook.io/mongodb-toan-tap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://janeto.gitbook.io/mongodb-toan-tap/truy-van-document-trong-mongodb/or-trong-mongodb.md).

# OR trong MongoDB

## Cú pháp <a href="#c-ph-p" id="c-ph-p"></a>

Để truy vấn Document dựa trên điều kiện OR, bạn cần sử dụng từ khóa **$or**. Cú pháp cơ bản của **OR** trong MongoDB như sau:

```
>db.mycol.find({
$or: [{key1: value1}, {key2:value2}]
}).pretty()
```

## Ví dụ <a href="#v-d" id="v-d"></a>

Ví dụ sau sẽ hiển thị tất cả loạt bài hướng dẫn (tutorials) được viết bởi 'tutorials point' hoặc có title là 'MongoDB Overview'

```
>db.mycol.find({$or:[{"by":"tutorials point"},{"title": "MongoDB Overview"}]}).pretty()

{

"_id": ObjectId(7df78ad8902c),

"title": "MongoDB Overview",

"description": "MongoDB is no sql database",

"by": "tutorials point",

"url": "http://www.tutorialspoint.com",

"tags": ["mongodb", "database", "NoSQL"],

"likes": "100"

}

>
```
