# Rego 102: Combining queries with AND/OR and custom messages

DevFeed: [Rego 102: Combining queries with AND/OR and custom messages](<https://devfeed.tech/articles/rego-102-combining-queries-with-and-or-and-custom-messages-8062.md>)

Original publisher: [Read original article](<https://snyk.io/blog/rego-for-beginners-part-2/>)

Author: Jasper Van der Jeugt; Becki Lee

Published: 2023-11-09T06:00:00Z

Content type: article

Language: en

Sources: [Blog RSS Feed | Snyk](<https://devfeed.tech/sources/blog-rss-feed-snyk.md>)

Topics: [rego](<https://devfeed.tech/topics/rego.md>), [opa](<https://devfeed.tech/topics/opa.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Cloud](<https://devfeed.tech/topics/cloud.md>), [Infrastructure as code](<https://devfeed.tech/topics/infrastructure-as-code.md>), [JSON](<https://devfeed.tech/topics/json.md>), [YAML](<https://devfeed.tech/topics/yaml.md>)

Tags: [beginner](<https://devfeed.tech/tags/beginner.md>), [blog](<https://devfeed.tech/tags/blog.md>), [blog-post](<https://devfeed.tech/tags/blog-post.md>), [cloud-security](<https://devfeed.tech/tags/cloud-security.md>), [code](<https://devfeed.tech/tags/code.md>), [developer](<https://devfeed.tech/tags/developer.md>), [devrel](<https://devfeed.tech/tags/devrel.md>), [enablement](<https://devfeed.tech/tags/enablement.md>), [guide](<https://devfeed.tech/tags/guide.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [iac-security](<https://devfeed.tech/tags/iac-security.md>), [opa](<https://devfeed.tech/tags/opa.md>), [policy](<https://devfeed.tech/tags/policy.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rego](<https://devfeed.tech/tags/rego.md>), [snyk-cloud](<https://devfeed.tech/tags/snyk-cloud.md>), [snyk-iac](<https://devfeed.tech/tags/snyk-iac.md>)

## AI overview

A beginner-focused guide to intermediate Rego syntax, explaining how to combine queries with AND and OR and introduce custom messages. It describes how OPA evaluates Rego policies against JSON or YAML input documents.

## Source excerpt

Learn how to use AND and OR rules and custom messages using OPA and Rego in the second part of our beginner's guide to Rego.