Administer > Database Administration > Data persistence > Queries > Create a query using an or statement or an and statement

Create a query using an or statement or an and statement

Applies to User Roles:

System Administrator

Example: Retrieve all contacts records where the Company is either DEFAULT or advantage, and the value in the Contact Name field begins with the letter B.

In this example, we perform a complex query using a combination of logical operators to query the contacts.qbe form.

To create a query using an or statement or an and statement:

  1. Click Tailoring > Database Manager.
  2. Type contacts in the Form field, and then click Search.
  3. Double-click the contacts form from the list of returned records.
  4. On the Contact Information form, open the More Actions menu.
  5. Select Expert Search.
  6. In the Query field, type (company=“advantage” or company=“DEFAULT”) and contact.name#“B”, and then click Search.
    This query may result in a partially keyed search. If so, you can optionally enter a time limit in your query prior to executing.
  7. Click any record in the list of returned records to view the details.

Note: If you type the same expression without using parentheses, such as company=“advantage” or company=“DEFAULT” and contact.name#“B”, the and operator takes precedence over the or operator and returns a different set of records. This query is less restricted and returns records with a value of either DEFAULT or advantage.