---
updatedAt: 2026-04-08T10:25:27.000Z
---

# Create a database query - CreateQuery or Classic Query

Used to create a query of a Acoustic Campaign database.

## Prerequisites

A query can search for values within database columns, relational table
columns, and also filter by mailing activity.

**Note:** Updates were made to this call to allow users to use the below
criteria in the CreateQuery call.

* Create a database query using behavioral query criteria: Examples of Behavioral criteria that can be used within the CreateQuery API call to create a query of an Acoustic Campaign database.
* Create a Query of a database by using Multiple Query
  Expressions: Examples of Multiple query expressions that can be used within the CreateQuery API call to build a query that contains data filters and search conditions that define the scope of an Acoustic Campaign database search.
* Create a database query using time-based operators: Examples of time-based operators that can be used within the CreateQuery API call to build a query that uses time-based operators to pull information for a specific timeframe within an Acoustic Campaign query.
* Create a database query using universal behavior criteria: Examples of Universal Behavior criteria that can be used within the CreateQuery API call to show if a behavior was or was not attained for a specific timeframe within an Acoustic Campaign query.
* Create a database query using relational table criteria: Examples of relational table criteria that can be used within the CreateQuery API call to pull a range of data from an Acoustic Campaign relational table.
* Create a database query using profile criteria: Examples of profile-based operators that can be used within the CreateQuery API call to show exact or a range of data within an Acoustic Campaign query.

### Syntax of the request and response XML for CreateQuery {#tocstep1 .makeTOC}

Operation: \<CreateQuery>

[block:parameters]
{
  "data": {
    "h-0": "Elements",
    "h-1": "Description",
    "0-0": "QUERY_NAME",
    "0-1": "The name of the new query.",
    "1-0": "PARENT_LIST_ID",
    "1-1": "The ID of the database being queried.",
    "2-0": "PARENT_FOLDER_ID (Optional)",
    "2-1": "The ID of the folder within which to save the query. If not specified, it is stored in the root of Shared or Private based on VISIBILITY.",
    "3-0": "SELECT_COLUMNS (Optional)",
    "3-1": "A pipe-separated list of fields available for personalization.",
    "3-2": "ONLY HONORED BY CLASSIC QUERIES",
    "4-0": "ALLOW_FIELD_CHANGE (Optional)",
    "4-1": "Defines whether to allow users to change the fields available for personalization when editing or creating a new query from this query. If not specified, the default is 1 (Allow Changes). Valid values are: 0 – Do not allow changes 1 – Allow Changes.",
    "4-2": "ONLY HONORED BY CLASSIC QUERIES",
    "5-0": "**CHILD ELEMENTS** ",
    "5-1": "Description",
    "6-0": "CRITERIA",
    "6-1": "Describes the expressions to perform on one or more columns in the database.",
    "7-0": "EXPRESSION",
    "7-1": "Describes a single expression to perform on a column. One or more EXPRESSION elements can exist within the CRITERIA element.",
    "7-2": "<EXPRESSION criteria_type=’behavior‘>\n<EXPRESSION criteria_type=’relational_table‘>\n<EXPRESSION criteria_type=’profile‘>\n<EXPRESSION criteria_type=’rt_profile’>",
    "8-0": "LOCKED_EXPRESSION (Optional)",
    "8-1": "Only one of these elements can exist.",
    "8-2": "<LOCKED_EXPRESSION criteria_type=’profile’>\n <OPERATOR>is in query </OPERATOR>\n<ID>[another query id]</ID> </LOCKED_EXPRESSION>",
    "9-0": "COLUMN (Optional)",
    "9-1": "Column name of the database or relational table. Required for ‘profile’ and ‘rt\\_profile’ criteria. Attribute name for universal behavior elements",
    "10-0": "OPERATOR (Required)",
    "10-1": "-   is blank\n    -   is not blank\n    -   anniversary is\n    -   today is\n    -   is after\n    -   is not after\n    -   is before\n    -   is not before\n    -   contains\n    -   does not contain\n    -   starts with\n    -   does not start with\n    -   ends with\n    -   does not end with\n    -   is equal to\n    -   is not equal to\n    -   is less than\n    -   is not less than or equal to\n    -   is greater than\n    -   is greater than or equal to\n    -   is after\n    -   is before\n    -   year is equal to\n    -   month is equal to\n    -   day is equal to\n    -   is equal to one of the following\n    -   is not equal to one of the following\n    -   contains one of the following\n    -   does not contain one of the following\n    -   starts with one of the following\n    -   does not start with one of the following\n    -   is between\n    -   is within the last\n    -   is not within the last\n    -   is within the next\n    -   is not within the next\n    -   is exactly\n    -   is not exactly\n    -   is within\n    -   is not within\n    -   is within the last range of\n    -   is in contact list\n    -   is not in contact list\n    -   is in query\n    -   is not in query\n\nAvailable operators for ‘relational_table’ criteria type:\n    -   match\n    -   not match\n\n  Available operators for ‘behavior’ criteria type:\n    -   has submitted web form\n    -   has not submitted web form\n    -   has visited web site\n    -   has not visited web site\n    -   have visited web page\n    -   has not visited web page\n    -   has triggered custom tracking event\n    -   has not triggered custom tracking event\n    -   has been sent email\n    -   has not been sent email\n    -   has clicked link in email\n    -   has not clicked link in email\n    -   has opened email\n    -   has not opened email\n    -   has attained ub event\n    -   has not attained ub event\n    -   has downloaded file\n    -   has not downloaded file\n    -   has been in program\n    -   has not been in program",
    "11-0": "VALUE (Optional)",
    "11-1": "Required when using one of the following operators:\n    -   contains\n    -   does not contain\n    -   starts with\n    -   does not start with\n    -   ends with\n    -   does not end with\n    -   is equal to\n    -   is not equal to\n    -   is less than\n    -   is less than or equal to\n    -   is greater than\n    -   is greater than or equal to\n    -   is after\n    -   is before\n    -   year is equal to\n    -   month is equal to\n    -   day is equal to",
    "12-0": "TIMEFRAME (Optional)",
    "12-1": "These are the following timeframes that can be used:\n    -   at any time\n    -   on today\n    -   before today\n    -   before today on\n    -   before\n    -   after\n    -   between\n    -   within\n    -   the last\n    -   exactly\n    -   more than\n    -   less than",
    "12-2": "These are the following operators that can use timeframes:\n    -   has submitted web form\n    -   has not submitted web form\n    -   has visited web site\n    -   has not visited web site\n    -   has visited web page\n    -   has not visited web page\n    -   has triggered custom tracking event\n    -   has not triggered custom tracking event\n    -   has been sent email\n    -   has not been sent email\n    -   has clicked link in email\n    -   has not clicked link in email\n    -   has opened email\n    -   has not opened email\n    -   has attained ub event\n    -   has not attained ub event\n    -   has downloaded file\n    -   has not downloaded file\n    -   is in query\n    -   is not in query\n    -   has been in program\n    -   has not been in program\n    -   is in stages\n    -   is not in stages",
    "13-0": "TIME_UNIT (Optional)",
    "13-1": "These are the following time units that can be used:\n    -   days\n    -   weeks\n    -   months",
    "13-2": "Can be used with these operators:\n    -   is within the last\n    -   is not within the last\n    -   is within the next\n    -   is not within the next\n    -   is exactly\n    -   is not exactly\n    -   anniversary is\n    -   is within\n    -   is not within\n    -   is within the last range of\n\nCan be used with these time frames:\n    -   within the last\n    -   exactly\n    -   more than\n    -   less than",
    "14-0": "UNIT",
    "14-1": "-   ago\n-   away",
    "14-2": "Used with TIME\\_UNIT and the following operators:\n    -   is exactly\n    -   is not exactly\n    -   anniversary is\n\n    And the following time frames:\n    -   exactly\n    -   more than\n    -   less than",
    "15-0": "PARENS (Optional)",
    "15-1": "Used to specify one or more left/right parentheses when relating more than one expression.",
    "16-0": "CONJUNCTION (Optional)",
    "16-1": "Used to specify AND or OR when relating multiple expressions.",
    "16-2": "<CONJUNCTION>AND/OR<CONJUNCTION>",
    "17-0": "RT_EXPRESSIONS (Optional)",
    "17-1": "Child element to an EXPRESSION element when criteria_type=’relational_table’. This element itself can have child EXPRESSION elements with criteria_type=’rt_profile’",
    "17-2": "Example RT expression:\n    <EXPRESSION criteria_type=’relational_table’>\n    <OPERATOR>match/not match\\</OPERATOR\\>\n    <ID>[rt id]\\<ID\\>\n    <RT_EXPRESSIONS>\n    <EXPRESSION criteria_type=’rt_profile’> [any valid elements for\n    profile criteria]\\\n    </EXPRESSION>\n    </RT_EXPRESSIONS>\n    </EXPRESSION>",
    "18-0": "CHANNEL (Optional)",
    "18-1": "Channel Type: PUSH SMS EMAIL \nUsed with the following operators: NEVER-JOINED,  OPTED-OUT,  OPTED-IN",
    "18-2": "<EXPRESSION criteria_type=’profile’>\n <OPERATOR>NEVER-JOINED/OPTED-OUT/OPTED-IN</OPERATOR>\n<CHANNEL>SMS/PUSH\\</CHANNEL>\n<VALUES>\n<VALUE>[channel qualifier 1]</VALUE>\n<VALUE>[channel qualifier 2]</VALUE>\n    or\n<ANY>true</ANY>\n</VALUES>\n</EXPRESSION>",
    "19-0": "UB_EXPRESSIONS (Optional)",
    "19-1": "Child element to an EXPRESSION element when criteria_type=’behavior’ and operator is UB operator. This element itself can have child EXPRESSION elements with criteria_type=’behavior’",
    "19-2": "<EXPRESSION criteria_type=’behavior’>\n<OPERATOR>has attained ub event/has not attained ub event</OPERATOR>\n<ID>\\</ID>\n<TIMEFRAME>is exactly</TIMEFRAME>\n<VALUE>10</VALUE>\n<TIME_UNIT>days</TIME_UNIT>\n<UNIT>ago</UNIT>\n<UB_EXPRESSIONS>\n<EXPRESSION criteria_type=’profile’>\n<OPERATOR>[any profile operator]</OPERATOR>\n<COLUMN>[attribute name</COLUMN>\n</EXPRESSION>\n</UB\\_EXPRESSIONS>\n</EXPRESSION>",
    "20-0": "EMAIL_LINK (Optional)",
    "20-1": "Used with behavior criteria and the following operators:\n    -   has clicked link in email\n    -   has not clicked link in email",
    "20-2": "<EXPRESSION criteria_type=’behavior’>\n    <OPERATOR>has clicked link in email</OPERATOR>\n    <ID>[mailing id]</ID>\n    <EMAIL_LINK>[link name]</EMAIL_LINK>\n    <TIMEFRAME>is within the last</TIMEFRAME>\n    <VALUE>10\\</VALUE>\n    <TIME_UNIT>weeks</TIME_UNIT>\n    </EXPRESSION>",
    "21-0": "EMAIL_LINKS (Optional)",
    "21-1": "Used with behavior criteria and the following operators:\n    -   has clicked any link\n    -   has not clicked link in email\n\nNote that with any link it goes from email_link to email_linkS.\n   <EMAIL_LINK>isAnyLink</EMAIL_LINK> would not work.\n    <EMAIL_LINKS isAnyLink=”true”/>is the correct way to build it.\n\nIf you were still building a query of a specific link click(s), then\n    you would continue to use EMAIL_LINK",
    "21-2": "<EXPRESSION criteria_type=”behavior”>\n<OPERATOR>has clicked link in email</OPERATOR>\n<ID>12345</ID>\n<EMAIL_LINKSisAnyLink=”true”/>\n<TIMEFRAME>on today</TIMEFRAME>\n</EXPRESSION>",
    "22-0": "WEB_FORM_NAME (Optional)",
    "22-1": "Used with behavior criteria and the following operators:\n    -   has submitted web form\n    -   has not submitted web form",
    "22-2": "<EXPRESSION criteria_type=’behavior’\\>\\\n<OPERATOR>has submitted web form</OPERATOR>\n<WEB_FORM_NAME>[web form name]</WEB_FORM_NAME>\n<TIMEFRAME>on today/TIMEFRAME>\n</EXPRESSION>",
    "23-0": "WEB_SITE (Optional)",
    "23-1": "Used with behavior criteria and the following operators:\n    -   has visited web site\n    -   has not visited web site",
    "23-2": "<EXPRESSION criteria_type=’behavior’>\n <OPERATOR>has submitted web form</OPERATOR>\n<WEB_SITE>[website/domain name]</WEB_SITE>\n<TIMEFRAME>at any time</TIMEFRAME>\n</EXPRESSION>",
    "24-0": "WEB_PAGE (Optional)",
    "24-1": "Used with behavior criteria and the following operators:\n    -   has visited web page\n    -   has not visited web page",
    "24-2": "<EXPRESSION criteria_type=’behavior’>\n<OPERATOR>has visited web page</OPERATOR>\n<WEB_PAGE>[web page]</WEB_PAGE>\n<TIMEFRAME>at any time</TIMEFRAME>\n</EXPRESSION>",
    "25-0": "FILE (Optional)",
    "25-1": "Used with behavior criteria and the following operators:\n    -   has downloaded file\n    -   Has not downloaded file",
    "25-2": "<EXPRESSION criteria_type=’behavior’>\n<OPERATOR>has downloaded file</OPERATOR>\n<FILE>[file path]</FILE>\n<TIMEFRAME>at any time</TIMEFRAME>\n</EXPRESSION>",
    "26-0": "EVENT\\_NAME (Optional)",
    "26-1": "Used with behavior criteria and the following operators:\n    -   has triggered custom tracking event\n    -   has not triggered custom tracking event",
    "26-2": "<EXPRESSION criteria_type=’behavior’>\n<OPERATOR\\>has triggered custom tracking event</OPERATOR>\n<EVENT_NAME>[file path]</EVENT_NAME>\n<FRIENDLY_NAME>[friendly name] or ANY element\\</FRIENDLY_NAME>\n<TIMEFRAME>at any time</TIMEFRAME>\n</EXPRESSION>",
    "27-0": "FRIENDLY\\_NAME (Optional)",
    "27-1": "Used with behavior criteria and the following operators:\n    -   has triggered custom tracking event\n    -   has not triggered custom tracking event",
    "27-2": "<EXPRESSION criteria_type=’behavior’>\n<OPERATOR>has triggered custom tracking event</OPERATOR>\n<EVENT_NAME>[file path]</EVENT_NAME>\n<FRIENDLY_NAME>[friendly name] or ANY element</FRIENDLY\\NAME>\n<TIMEFRAME>at any time</TIMEFRAME>\n</EXPRESSION>",
    "28-0": "ANY (Optional)",
    "28-1": "Can be used as child element of the following\n    elements: FRIENDLY\\_NAME VALUES",
    "28-2": "<ANY>true/false</ANY>",
    "29-0": "ID (Optional)",
    "29-1": "Used with the following operators:\n    -   is in contact list\n    -   is not in contact list\n    -   is in query\n    -   is not in query\n    -   has been sent email\n    -   has not been sent email\n    -   has clicked link in email\n    -   has not opened email\n    -   has opened email\n    -   has attained ub event\n    -   has no attained ub event\n    -   has been in program\n    -   has not been in program\n    -   match\n    -   not match",
    "29-2": "<EXPRESSION criteria_type=’behavior’>\n<OPERATOR>has been in program</OPERATOR>\n<ID>[program id]</ID>\n<TIMEFRAME>at any time</TIMEFRAME>\n</EXPRESSION>\n <EXPRESSION criteria_type=’profile’>\n<OPERATOR>is in query</OPERATOR>\n<ID>[query id]</ID>\n<TIMEFRAME>at any time</TIMEFRAME>\n</EXPRESSION>\n<EXPRESSION criteria_type=’profile’>\n<OPERATOR>is in contact list\\</OPERATOR>\n<ID>[contact list id]</ID>\n</EXPRESSION>\n<EXPRESSION criteria_type=’behavior’>\n<OPERATOR>has been sent email/has opened email</OPERATOR>\n<ID>[mailing id]</ID>\n<TIMEFRAME>at any time</TIMEFRAME>\n</EXPRESSION>",
    "30-0": "TABLE_ID (Optional)",
    "30-1": "Used for child relational table expressions",
    "31-0": "Response: <RESULT\\>",
    "32-0": "SUCCESS",
    "32-1": "TRUE if successful",
    "32-2": "<Envelope>\n<Body>\n<RESULT>\n <SUCCESS>TRUE</SUCCESS>\n<ListId>25874</ListId>\n</RESULT>\n</Body>\n</Envelope>"
  },
  "cols": 3,
  "rows": 33
}
[/block]

 
This interface supports programmatically creating a **Classic query** of an Acoustic Campaign database.

[block:parameters]
{
  "data": {
    "h-0": "Operation",
    "h-1": "<CreateQuery>",
    "0-0": "Elements",
    "0-1": "QUERY_NAME",
    "0-2": "The name of the new query.",
    "1-0": "",
    "1-1": "PARENT_LIST_ID",
    "2-1": "VISIBILITY",
    "1-2": "The ID of the database being queried.",
    "2-2": "Defining the visibility of the new query. Valid values are:\n    -   0 – Private\n    -   1 – Shared",
    "3-1": "PARENT\\_FOLDER\\_ID",
    "3-2": "**Optional**",
    "4-1": "SELECT_COLUMNS",
    "4-2": "**Optional**",
    "5-1": "ALLOW_FIELD_CHANGE",
    "5-2": "**Optional**",
    "6-1": "Child Element",
    "6-0": "",
    "6-2": "EXPRESSION",
    "3-3": "The ID of the folder within which to save the query. If not specified, it is stored in the root of Shared or Private based on VISIBILITY.",
    "4-3": "A pipe-separated list of fields available for personalization.",
    "5-3": "Defines whether to allow users to change the fields available for personalization when editing or creating a new query from this query. If not specified, the default is 1 (Allow Changes). Valid values are:\n    -   0 – Do not allow changes.\n    -   1 – Allow Changes",
    "6-3": "Describes the expressions to perform on one or more columns in the database.",
    "7-2": "CRITERIA",
    "7-3": "Specifies if criteria are locked or editable. Valid values are:\n\n    -   Locked\n    -   Editable.\n\nIf not specified, the default is marked Editable.",
    "8-0": "**Child Element**",
    "8-1": "**Optional**",
    "8-2": "EXPRESSION",
    "8-3": "Describes a single expression to perform on a column. One or more EXPRESSION elements can exist within the CRITERIA element.",
    "9-0": "",
    "9-1": "**Optional**",
    "9-2": "TYPE",
    "9-3": "The type of evaluation. Valid values are: NE – Numeric DE –\n    Date/Time TE – Text:\n\n    -   NE – Numeric\n    -   DE – Date/Time\n    -   TE – Text\n\n**Note:** TYPE is required when defining database expressions but not specified for relational table expressions.",
    "10-0": "Element",
    "10-1": "COLUMN_NAME",
    "10-2": "**Optional**",
    "10-3": "The name of the database field.\n  Note: COLUMN\\_NAME is required when defining database expressions but not specified for relational table expressions.",
    "11-1": "OPERATORS",
    "11-2": "**Optional**",
    "11-3": "The operator that is used for comparison. Valid values are: != \\< \\>\n    = IS NOT null IS null LIKE NOT like IN NOT in BETWEENOPERATORS is required when defining database expressions but not specified for relational table expressions.\n\n**Note:** OPERATORS is required when defining database expressions but not specified for relational table expressions.",
    "12-1": "VALUES",
    "12-2": "**Optional**",
    "12-3": "The value being compared to the Acoustic Campaign database field.\nThis can include text or a numeric or date value. It can also include a list of values or the name of a Column. If specifying a database column, surround with square brackets, such as: [My TextColumn]. If specifying a list of values, use the pipe character ( | ) to separate values in a list. Required for all operators other than IS NOT null and IS null.\n\n**Note:** VALUES is not specified for relational table expressions.",
    "13-0": "",
    "13-1": "TABLE_ID",
    "13-2": "**Optional**",
    "13-3": "The ID of the Relational Table when one or more relational table expressions are being defined.",
    "14-1": "LEFT_PARENS",
    "14-2": "**Optional**",
    "14-3": "Used to specify one or more left parentheses when relating more than one expression. For example, two left parentheses would be indicated as: ((",
    "15-1": "RIGHT_PARENS",
    "15-2": "**Optional**",
    "15-3": "Used to specify one or more right parentheses when relating more than one expression. For example, two right parentheses would be\nindicated as: ))",
    "16-1": "AND_OR",
    "16-2": "**Optional**",
    "16-3": "Used to specify AND or OR when relating multiple expressions.",
    "18-1": "**ChildElements**",
    "17-1": "RT_EXPRESSION",
    "17-2": "**Optional**",
    "17-3": "Describes a single expression to perform on a relational table column. One or more RT_EXPRESSION elements can exist within the EXPRESSION element.\n\n**Note:** The RT\\_EXPRESSION child elements are the same for database criteria and relational table criteria. See EXPRESSION section within the CRITERIA section for definition.",
    "18-2": "TYPE",
    "18-3": "The type of evaluation. Valid values are:\n    -   NE – Numeric\n    -   DE – Date/Time\n    -   TE – Text",
    "19-1": "",
    "19-2": "COLUMN_NAME",
    "19-3": "The name of the relational table field.",
    "20-2": "OPERATORS",
    "20-3": "The operator that is used for comparison. Valid values are: != \\< \\> = IS NOT null IS null LIKE NOT like IN NOT in BETWEEN",
    "21-2": "**Optional**",
    "21-1": "VALUES",
    "21-3": "The value being compared to the Acoustic Campaign relational table field. This can include text or a numeric or date value. It can also include a list of values or the name of a Column. If specifying a\nColumn, surround with square brackets, such as: [My Text Column]. If\nspecifying a list of values, use the pipe character ( | ) to\nseparate values in a list. Required for all operators other than IS\nNOT null and IS null.",
    "23-0": "",
    "23-1": "LEFT_PARENS",
    "23-2": "**Optional**",
    "23-3": "Used to specify one or more left parentheses when relating more than\none expression. For example, two left parentheses would be indicated as: ((",
    "24-1": "RIGHT_PARENS",
    "24-2": "**Optional**",
    "24-3": "Used to specify one or more right parentheses when relating more\nthan one expression. For example, two right parentheses would be\nindicated as: ))",
    "25-1": "AND_OR",
    "25-2": "*Optional**",
    "25-3": "Used to specify AND or OR when relating multiple expressions.",
    "27-1": "BEHAVIOR",
    "27-2": "**Optional**",
    "27-3": "Optional; defines the Behavior section of the query. Filters mailing\ncontacts by their activity.",
    "28-1": "OPTIONAL_OPERATOR",
    "28-2": "Specifies the operation or activity for which you are searching. Valid values are: 100– Opened 101 – Clicked 102 – Bounced 103 – No Activity",
    "29-1": "TYPE_OPERATOR",
    "29-2": "Specifies whether to search a particular mailing (or all mailings)\n    for the database. Valid values are: 110 – For Any Mailing (only\n    available if query is on the database that is designated to store\n    Automated Behavior Updates) 111 – For One Mailing",
    "30-1": "MAILING_ID",
    "30-2": "**Optional**",
    "30-3": "The ID of the mailing within which to search for contact activity.",
    "31-1": "REPORT_ID",
    "31-2": "**Optional**",
    "31-3": "Required when using the MAILING\\_ID parameter. The Report ID that identifies the mailing instance within which to search for contact activity.",
    "32-1": "LINK_NAME",
    "32-2": "**Optional**",
    "32-3": "The name of a link in a mailing. Used to include only contacts who clicked a particular link in a mailing.",
    "33-1": "WHERE_OPERATOR",
    "33-2": "**Optional**",
    "33-3": "Specifies whether to compare to an activity count, date of activity,\nor number of days since activity. Valid values are: 120 – Days Since Activity 121 – Activity Date 122 – Activity Count Only used when you specify For One Mailing and you do NOT include a No Activity parameter.",
    "34-1": "CRITERIA_OPERATOR",
    "34-2": "**Optional**",
    "34-3": "The operator that is used for comparison. Required if WHERE_OPERATOR is included. Valid values are: != \\< \\> = \\>= \\<=\nBETWEEN",
    "35-1": "VALUES",
    "35-2": "**Optional**",
    "35-3": "The value that you are comparing to the contact activity count, date of activity, or number of days since activity. Might be numeric or date value. If operator is BETWEEN, two values must be provided delimited by a pipe. Required if WHERE\\_OPERATOR is included.",
    "36-0": "Example",
    "36-1": "<Envelope>\n          <Body>\n            <CreateQuery>\n              <QUERY_NAME>Has_Mobile_30_Zip</QUERY_NAME>\n              <PARENT_LIST_ID>17607</PARENT_LIST_ID>\n              <VISIBILITY>0</VISIBILITY>\n              <PARENT_FOLDER_ID>9512</PARENT_FOLDER_ID>\n              <ALLOW_FIELD_CHANGE>0</ALLOW_FIELD_CHANGE>\n              <SELECT_COLUMNS>Last_Name|First_Name</SELECT_COLUMNS>\n              <CRITERIA>\n                <TYPE>editable</TYPE>\n                <EXPRESSION>\n                  <TYPE>TE</TYPE>\n                  <COLUMN_NAME>Zip</COLUMN_NAME>\n                  <OPERATORS>\n                    <![CDATA[BETWEEN]]>\n                  </OPERATORS>\n                  <VALUES>\n                    <![CDATA[30000|30999]]>\n                  </VALUES>\n                  <LEFT_PARENS>(</LEFT_PARENS>\n                </EXPRESSION>\n                <EXPRESSION>\n                  <AND_OR>AND</AND_OR>\n                  <TYPE>TE</TYPE>\n                  <COLUMN_NAME>Mobile</COLUMN_NAME>\n                  <OPERATORS>\n                    <![CDATA[IS NOT null]]>\n                  </OPERATORS>\n                  <RIGHT_PARENS>)</RIGHT_PARENS>\n                </EXPRESSION>\n                <EXPRESSION>\n                  <TABLE_ID>4645</TABLE_ID>\n                  <\n                  AND_OR>AND</AND_OR>\n                  <LEFT_PARENS>(</LEFT_PARENS>\n                  <RT_EXPRESSION>\n                    <TYPE>TE</TYPE>\n                    <COLUMN_NAME>Purchase Type</COLUMN_NAME>\n                    <OPERATORS>\n                      <![CDATA[=]]>\n                    </OPERATORS>\n                    <VALUES>\n                      <![CDATA[New]]>\n                    </VALUES>\n                    <LEFT_PARENS>(</LEFT_PARENS>\n                  </RT_EXPRESSION>\n                  <RT_EXPRESSION>\n                    <AND_OR>AND</AND_OR>\n                    <TYPE>DE</TYPE>\n                    <COLUMN_NAME>Purchase Date</COLUMN_NAME>\n                    <OPERATORS>\n                      <![CDATA[>]]>\n                    </OPERATORS>\n                    <VALUES>\n                      <![CDATA[[Current Date]-3]]>\n                    </VALUES>\n                    <RIGHT_PARENS>)</RIGHT_PARENS>\n                  </RT_EXPRESSION>\n                </EXPRESSION>\n                <EXPRESSION>\n                  <TABLE_ID>8581</TABLE_ID>\n                  <AND_OR>OR</AND_OR>\n                  <RIGHT_PARENS>)</RIGHT_PARENS>\n                  <RT_EXPRESSION>\n                    <TYPE>TE</TYPE>\n                    <COLUMN_NAME>Expired</COLUMN_NAME>\n                    <OPERATORS>\n                      <![CDATA[=]]>\n                    </OPERATORS>\n                    <VALUES>\n                      <![CDATA[true]]>\n                    </VALUES>\n                  </RT_EXPRESSION>\n                </EXPRESSION>\n              </CRITERIA>\n              <BEHAVIOR>\n                <OPTION_OPERATOR>103</OPTION_OPERATOR>\n                <TYPE_OPERATOR>111</TYPE_OPERATOR>\n                <MAILING_ID>669614</MAILING_ID>\n                <REPORT_ID>502993</REPORT_ID>\n              </BEHAVIOR>\n            </CreateQuery>\n          </Body>\n        </Envelope>",
    "38-0": "Elements",
    "37-1": "<RESULT>",
    "37-0": "Response",
    "38-1": "SUCCESS",
    "38-2": "TRUE if successful",
    "39-1": "ListID",
    "39-2": "The ID of the query that was created.",
    "40-0": "Example",
    "40-1": "<Envelope>\n          <Body>\n            <RESULT>\n              <SUCCESS>TRUE</SUCCESS>\n              <ListId>25874</ListId>\n            </RESULT>\n          </Body>\n</Envelope>"
  },
  "cols": 4,
  "rows": 41
}
[/block]

## Create a database query using universal behavior criteria

<p class="shortdesc">Use Universal Behavior based operators to show if a behavior was or was not attained for a specific timeframe within a Query.</p>

<div class="section">
<p class="p">The table shows the Universal Behavior criteria that is now available for&nbsp;<a class="xref" title="Create Query" href="http://developer.ibm.com/customer-engagement/tutorials/create-query-database/" target="_blank" rel="noopener">Create Query</a>.</p>
</div>

<div class="section">
<h3 class="title sectiontitle">Criteria</h3>

<table class="table" border="1" summary="" frame="border" rules="all" cellspacing="0" cellpadding="4">
<tbody class="tbody">
<tr class="row">
<td class="entry" valign="top">
<p class="p">Query Description</p>
</td>
<td class="entry" valign="top">
<p class="p">Criteria Type</p>
</td>
<td class="entry" valign="top">
<p class="p">Operator for the UB</p>
</td>
<td class="entry" valign="top">
<p class="p">Attribute Name</p>
</td>
<td class="entry" valign="top">
<p class="p">Attribute Operator</p>
</td>
<td class="entry" valign="top">
<p class="p">Attribute Value</p>
</td>
<td class="entry" valign="top">
<p class="p">Timeframe</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Text</p>
</td>
<td class="entry" valign="top">
<p class="p">is equal to</p>
</td>
<td class="entry" valign="top">
<p class="p">Bob</p>
</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has not attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has not attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Text</p>
</td>
<td class="entry" valign="top">
<p class="p">contains one of the following</p>
</td>
<td class="entry" valign="top">
<p class="p">Bob, Susan</p>
</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Numeric</p>
</td>
<td class="entry" valign="top">
<p class="p">is between</p>
</td>
<td class="entry" valign="top">
<p class="p">3, 5</p>
</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has not attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has not attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Date</p>
</td>
<td class="entry" valign="top">
<p class="p">is within the last</p>
</td>
<td class="entry" valign="top">
<p class="p">5 days</p>
</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Date</p>
</td>
<td class="entry" valign="top">
<p class="p">is within the last range of</p>
</td>
<td class="entry" valign="top">
<p class="p">3-5 Days</p>
</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Date</p>
</td>
<td class="entry" valign="top">
<p class="p">is today</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has not attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has not attained ub event</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
</tbody>
</table>
</div>

## Create a database query using multiple query expressions

<div class="entry-content-block">
<h2 id="tocingredients" class="makeTOC">Prerequisites</h2>
<div class="inner">
<p>Multiple Query Expressions allow a user to build a query that contains data filters and search conditions that define the scope of a database search.</p>
</div>
</div>

<div class="entry-content-block">
<h3>Criteria type and an example calls for Multiple Query Expressions</h3>
<div>
<div class="section">

<div class="tablenoborder">
<table class="table" border="1" summary="" frame="border" rules="all" cellspacing="0" cellpadding="4">
<tbody class="tbody">
<tr class="row">
<td class="entry" valign="top">
<p class="p"><strong>Criteria Type</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong>And/Or</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong>Left Parens</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong>Column Name</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong>Operator</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong>Values</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong>Right Parens</strong></p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">profile</p>
</td>
<td class="entry" valign="top">
<p class="p">AND</p>
</td>
<td class="entry" valign="top">
<p class="p">(</p>
</td>
<td class="entry" valign="top">
<p class="p">first name</p>
</td>
<td class="entry" valign="top">
<p class="p">is blank</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">profile</p>
</td>
<td class="entry" valign="top">
<p class="p">OR</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">age</p>
</td>
<td class="entry" valign="top">
<p class="p">is not equal to</p>
</td>
<td class="entry" valign="top">
<p class="p">10</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">profile</p>
</td>
<td class="entry" valign="top">
<p class="p">OR</p>
</td>
<td class="entry" valign="top">
<p class="p">(</p>
</td>
<td class="entry" valign="top">
<p class="p">zipcode</p>
</td>
<td class="entry" valign="top">
<p class="p">is equal to one of the following</p>
</td>
<td class="entry" valign="top">
<p class="p">30052, 30033</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">profile</p>
</td>
<td class="entry" valign="top">
<p class="p">AND</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">anniversary</p>
</td>
<td class="entry" valign="top">
<p class="p">is not within the last</p>
</td>
<td class="entry" valign="top">
<p class="p">5 days</p>
</td>
<td class="entry" valign="top">
<p class="p">))</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<ol id="tutSteps">
<li data-stepcount="2">

<h3>Example Calls</h3>
<div>
<p class="p" dir="ltr">The criteria creates editable criteria. When&nbsp;<strong class="ph b">Email</strong>&nbsp;is not blank OR&nbsp;<strong class="ph b">Email</strong>&nbsp;is equal to&nbsp;<a class="xref" title="(Opens in a new tab or window)" href="https://developer.ibm.com/customer-engagement/wp-admin/test@sp.com" target="_blank" rel="noopener">test@sp.com</a></p>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;CreateQuery&gt;
    &lt;PARENT_LIST_ID&gt;348328&lt;/PARENT_LIST_ID&gt;
    &lt;QUERY_NAME&gt;xli_test_create_Q2&lt;/QUERY_NAME&gt;
    &lt;VISIBILITY&gt;1&lt;/VISIBILITY&gt;
    &lt;CRITERIA&gt;
      &lt;EXPRESSION criteria_type="profile"&gt;
        &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
        &lt;OPERATOR&gt;is not blank&lt;/OPERATOR&gt;
        &lt;COLUMN&gt;Email&lt;/COLUMN&gt;
      &lt;/EXPRESSION&gt;
      &lt;EXPRESSION criteria_type="profile"&gt;
        &lt;CONJUNCTION&gt;OR&lt;/CONJUNCTION&gt;
        &lt;OPERATOR&gt;is equal to&lt;/OPERATOR&gt;
        &lt;COLUMN&gt;Email&lt;/COLUMN&gt;
        &lt;WEB_SITE&gt;http://www.ibm.com&lt;/WEB_SITE&gt;
        &lt;VALUE&gt;test@sp.com&lt;/VALUE&gt;
      &lt;/EXPRESSION&gt;
    &lt;/CRITERIA&gt;
    &lt;CreateQuery&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;
</pre>
<p>&nbsp;</p>
<p class="p" dir="ltr">&nbsp;</p>
<div class="section">
<h3>Multiple Query Expression Example with Parenthesis</h3>
<p class="p" dir="ltr">This criteria creates Editable Criteria:</p>
<p class="p" dir="ltr">When&nbsp;<strong class="ph b">Email</strong>&nbsp;is not blank</p>
<p class="p" dir="ltr">OR (<strong class="ph b">Email</strong>&nbsp;is not blank</p>
<p class="p" dir="ltr">AND&nbsp;<strong class="ph b">Email</strong>&nbsp;is not blank)</p>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;CreateQuery&gt;
    &lt;PARENT_LIST_ID&gt;348328&lt;/PARENT_LIST_ID&gt;
    &lt;QUERY_NAME&gt;xli_test_create_Q2&lt;/QUERY_NAME&gt;
    &lt;VISIBILITY&gt;1&lt;/VISIBILITY&gt;
    &lt;CRITERIA&gt;
      &lt;EXPRESSION criteria_type="profile"&gt;
        &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
        &lt;OPERATOR&gt;is not blank&lt;/OPERATOR&gt;
        &lt;COLUMN&gt;Email&lt;/COLUMN&gt;
      &lt;/EXPRESSION&gt;
      &lt;EXPRESSION criteria_type="profile"&gt;
        &lt;PARENS&gt;(&lt;/PARENS&gt;
        &lt;CONJUNCTION&gt;OR&lt;/CONJUNCTION&gt;
        &lt;OPERATOR&gt;is not blank&lt;/OPERATOR&gt;
        &lt;COLUMN&gt;Email&lt;/COLUMN&gt;
      &lt;/EXPRESSION&gt;
      &lt;EXPRESSION criteria_type="profile"&gt;
        &lt;PARENS&gt;)&lt;/PARENS&gt;
        &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
        &lt;OPERATOR&gt;is not blank&lt;/OPERATOR&gt;
        &lt;COLUMN&gt;Email&lt;/COLUMN&gt;
      &lt;/EXPRESSION&gt;
    &lt;/CRITERIA&gt;
    &lt;CreateQuery&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;</pre>
</div>
</div>
</li>
</ol>
</div>

## Create database query using profile criteria

<p class="shortdesc">Use Profile based operators to show exact or a range of data within a Query.</p>

<div class="section">
<p class="p">The table shows the Profile criteria that is now available for&nbsp;<a class="xref" title="Create Query" href="https://developer.ibm.com/customer-engagement/tutorials/create-query-database/" target="_blank" rel="noopener">Create Query</a>.</p>
</div>

<div class="section">
<h3 class="title sectiontitle">Criteria</h3>
<div class="tablenoborder">​
<table class="table" border="1" summary="" frame="border" rules="all" cellspacing="0" cellpadding="4">
<tbody class="tbody">
<tr class="row">
<td class="entry" valign="top">
<p class="p"><strong>operator</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong>Column Name</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong>values</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong>Channel</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong>Locked Query Id/Name</strong></p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is blank</p>
</td>
<td class="entry" valign="top">
<p class="p">first name</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">someOtherQueryId</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is not blank</p>
</td>
<td class="entry" valign="top">
<p class="p">first name</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is between</p>
</td>
<td class="entry" valign="top">
<p class="p">age</p>
</td>
<td class="entry" valign="top">
<p class="p">10 and 20</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is equal to</p>
</td>
<td class="entry" valign="top">
<p class="p">age</p>
</td>
<td class="entry" valign="top">
<p class="p">10</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is not equal to</p>
</td>
<td class="entry" valign="top">
<p class="p">age</p>
</td>
<td class="entry" valign="top">
<p class="p">10</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">someOtherQueryId</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is equal to one of the following</p>
</td>
<td class="entry" valign="top">
<p class="p">zipcode</p>
</td>
<td class="entry" valign="top">
<p class="p">30052, 30033</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is not equal to one of the following</p>
</td>
<td class="entry" valign="top">
<p class="p">zipcode</p>
</td>
<td class="entry" valign="top">
<p class="p">30052, 30033</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is within the last range of</p>
</td>
<td class="entry" valign="top">
<p class="p">anniversary</p>
</td>
<td class="entry" valign="top">
<p class="p">5 and 10 days</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is within the next</p>
</td>
<td class="entry" valign="top">
<p class="p">anniversary</p>
</td>
<td class="entry" valign="top">
<p class="p">10 days</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">someOtherQueryId</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is not within the last</p>
</td>
<td class="entry" valign="top">
<p class="p">anniversary</p>
</td>
<td class="entry" valign="top">
<p class="p">5 days</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is in contact list</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">list id or name</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is not in contact list</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">list id or name</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">someOtherQueryId</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is not in query</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">someOtherQueryId</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">OPTED-IN</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">any qualifier</p>
</td>
<td class="entry" valign="top">
<p class="p">PUSH</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">OPTED-OUT</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">single qualifier</p>
</td>
<td class="entry" valign="top">
<p class="p">SMS</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">NEVER-JOINED</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">multiple qualifiers</p>
</td>
<td class="entry" valign="top">
<p class="p">PUSH</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</div>

## Create a database query using time-based operators

<p class="shortdesc">Use Time based operators to pull information for a specific timeframe within a Query.</p>

<div class="section">
<p class="p">Examples of API Calls for&nbsp;<a class="xref" title="This interface supports programmatically creating a query of an [shortcode-variables slug=" href="https://developer.ibm.com/customer-engagement/tutorials/create-query-database/">Create Query</a>&nbsp;by using various time-based operators.</p>
</div>

<div class="example">
<h3 class="title sectiontitle">Example Calls</h3>
</div>

<div class="section">
<h3 class="title sectiontitle"><strong class="ph b">Contains &ldquo;on today&rdquo; new query criteria</strong></h3>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;CreateQuery&gt;
    &lt;PARENT_LIST_ID&gt;348328&lt;/PARENT_LIST_ID&gt;
    &lt;QUERY_NAME&gt;xli_test_create_Q10&lt;/QUERY_NAME&gt;
    &lt;VISIBILITY&gt;1&lt;/VISIBILITY&gt;
    &lt;CRITERIA&gt;
      &lt;EXPRESSION criteria_type="behavior"&gt;
        &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
        &lt;OPERATOR&gt;has visited web page&lt;/OPERATOR&gt;
        &lt;WEB_PAGE&gt;http://www.ibm.com&lt;/WEB_PAGE&gt;
        &lt;TIMEFRAME&gt;on today&lt;/TIMEFRAME&gt;
      &lt;/EXPRESSION&gt;
    &lt;/CRITERIA&gt;
    &lt;CreateQuery&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;
</pre>
</div>

<div class="section">
<h3 class="title sectiontitle"><strong class="ph b">Contains &ldquo;Less Than or More Than&rdquo; new query criteria</strong></h3>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;CreateQuery&gt;
    &lt;PARENT_LIST_ID&gt;348328&lt;/PARENT_LIST_ID&gt;
    &lt;QUERY_NAME&gt;xli_test_create_Q10&lt;/QUERY_NAME&gt;
    &lt;VISIBILITY&gt;1&lt;/VISIBILITY&gt;
    &lt;CRITERIA&gt;
      &lt;EXPRESSION criteria_type="behavior"&gt;
        &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
        &lt;OPERATOR&gt;has visited web page&lt;/OPERATOR&gt;
        &lt;WEB_PAGE&gt;http://www.ibm.com&lt;/WEB_PAGE&gt;
        &lt;TIMEFRAME&gt;less than&lt;/TIMEFRAME&gt;
        &lt;VALUE&gt;80&lt;/VALUE&gt;
        &lt;TIME_UNIT&gt;days&lt;/TIME_UNIT&gt;
      &lt;/EXPRESSION&gt;
    &lt;/CRITERIA&gt;
    &lt;CreateQuery&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;
</pre>
</div>

<div class="section">
<h3 class="title sectiontitle"><strong class="ph b">Contains &ldquo;Within the last&rdquo; new query criteria</strong></h3>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;CreateQuery&gt;
    &lt;PARENT_LIST_ID&gt;348328&lt;/PARENT_LIST_ID&gt;
    &lt;QUERY_NAME&gt;xli_test_create_Q10&lt;/QUERY_NAME&gt;
    &lt;VISIBILITY&gt;1&lt;/VISIBILITY&gt;
    &lt;CRITERIA&gt;
      &lt;EXPRESSION criteria_type="behavior"&gt;
        &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
        &lt;OPERATOR&gt;has visited web page&lt;/OPERATOR&gt;
        &lt;WEB_PAGE&gt;http://www.ibm.com&lt;/WEB_PAGE&gt;
        &lt;TIMEFRAME&gt;within the last&lt;/TIMEFRAME&gt;
        &lt;VALUE&gt;80&lt;/VALUE&gt;
        &lt;TIME_UNIT&gt;days&lt;/TIME_UNIT&gt;
      &lt;/EXPRESSION&gt;
    &lt;/CRITERIA&gt;
    &lt;CreateQuery&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;
</pre>
</div>

<div class="section">
<h3 class="title sectiontitle"><strong class="ph b">Contains &ldquo;Before Today&rdquo; new query criteria</strong></h3>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;CreateQuery&gt;
    &lt;PARENT_LIST_ID&gt;348328&lt;/PARENT_LIST_ID&gt;
    &lt;QUERY_NAME&gt;xli_test_create_Q10&lt;/QUERY_NAME&gt;
    &lt;VISIBILITY&gt;1&lt;/VISIBILITY&gt;
    &lt;CRITERIA&gt;
      &lt;EXPRESSION criteria_type="behavior"&gt;
        &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
        &lt;OPERATOR&gt;has visited web page&lt;/OPERATOR&gt;
        &lt;WEB_PAGE&gt;http://www.ibm.com&lt;/WEB_PAGE&gt;
        &lt;TIMEFRAME&gt;before today&lt;/TIMEFRAME&gt;
      &lt;/EXPRESSION&gt;
    &lt;/CRITERIA&gt;
    &lt;CreateQuery&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;</pre>
</div>

## Create a database query using universal behavior criteria

<p class="shortdesc">Use Universal Behavior based operators to show if a behavior was or was not attained for a specific timeframe within a Query.</p>

<div class="section">
<p class="p">The table shows the Universal Behavior criteria that is now available for&nbsp;<a class="xref" title="Create Query" href="http://developer.ibm.com/customer-engagement/tutorials/create-query-database/" target="_blank" rel="noopener">Create Query</a>.</p>
</div>

<div class="section">
<h3 class="title sectiontitle">Criteria</h3>
<div class="tablenoborder">
<table class="table" border="1" summary="" frame="border" rules="all" cellspacing="0" cellpadding="4">
<tbody class="tbody">
<tr class="row">
<td class="entry" valign="top">
<p class="p">Query Description</p>
</td>
<td class="entry" valign="top">
<p class="p">Criteria Type</p>
</td>
<td class="entry" valign="top">
<p class="p">Operator for the UB</p>
</td>
<td class="entry" valign="top">
<p class="p">Attribute Name</p>
</td>
<td class="entry" valign="top">
<p class="p">Attribute Operator</p>
</td>
<td class="entry" valign="top">
<p class="p">Attribute Value</p>
</td>
<td class="entry" valign="top">
<p class="p">Timeframe</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Text</p>
</td>
<td class="entry" valign="top">
<p class="p">is equal to</p>
</td>
<td class="entry" valign="top">
<p class="p">Bob</p>
</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has not attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has not attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Text</p>
</td>
<td class="entry" valign="top">
<p class="p">contains one of the following</p>
</td>
<td class="entry" valign="top">
<p class="p">Bob, Susan</p>
</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Numeric</p>
</td>
<td class="entry" valign="top">
<p class="p">is between</p>
</td>
<td class="entry" valign="top">
<p class="p">3, 5</p>
</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has not attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has not attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Date</p>
</td>
<td class="entry" valign="top">
<p class="p">is within the last</p>
</td>
<td class="entry" valign="top">
<p class="p">5 days</p>
</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Date</p>
</td>
<td class="entry" valign="top">
<p class="p">is within the last range of</p>
</td>
<td class="entry" valign="top">
<p class="p">3-5 Days</p>
</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has attained ub event</p>
</td>
<td class="entry" valign="top">
<p class="p">Date</p>
</td>
<td class="entry" valign="top">
<p class="p">is today</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">test has not attained UB event with attribute</p>
</td>
<td class="entry" valign="top">
<p class="p">behavior</p>
</td>
<td class="entry" valign="top">
<p class="p">has not attained ub event</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">&nbsp;</td>
<td class="entry" valign="top">
<p class="p">at any time</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>

## Create a database query using relational table criteria

<p class="shortdesc">Use Relational Table criteria within the&nbsp;<a title="Create Query" href="https://developer.ibm.com/customer-engagement/tutorials/create-query-database/" target="_blank" rel="noopener">Create Query</a>&nbsp;API call to pull a range of data from a Relational Table.</p>

<div class="section">
<h3 class="title sectiontitle">Overview</h3>
<p class="p">Criteria type and example calls that use Relational Table criteria.</p>
</div>

<div class="section">
<h3 class="title sectiontitle">Relational Table Criteria</h3>
<div class="tablenoborder">
<table class="table" border="1" summary="" frame="border" rules="all" cellspacing="0" cellpadding="4">
<tbody class="tbody">
<tr class="row">
<td class="entry" valign="top">
<p class="p"><strong class="ph b">Operator</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong class="ph b">Column Name</strong></p>
</td>
<td class="entry" valign="top">
<p class="p"><strong class="ph b">Values</strong></p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is blank</p>
</td>
<td class="entry" valign="top">
<p class="p">first name</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is not blank</p>
</td>
<td class="entry" valign="top">
<p class="p">first name</p>
</td>
<td class="entry" valign="top">&nbsp;</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is between</p>
</td>
<td class="entry" valign="top">
<p class="p">age</p>
</td>
<td class="entry" valign="top">
<p class="p">10 and 20</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is equal to</p>
</td>
<td class="entry" valign="top">
<p class="p">age</p>
</td>
<td class="entry" valign="top">
<p class="p">10</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is not equal to</p>
</td>
<td class="entry" valign="top">
<p class="p">age</p>
</td>
<td class="entry" valign="top">
<p class="p">10</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is equal to one of the following</p>
</td>
<td class="entry" valign="top">
<p class="p">zipcode</p>
</td>
<td class="entry" valign="top">
<p class="p">30052, 30033</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is not equal to one of the following</p>
</td>
<td class="entry" valign="top">
<p class="p">zipcode</p>
</td>
<td class="entry" valign="top">
<p class="p">30052, 30033</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is within the last range of</p>
</td>
<td class="entry" valign="top">
<p class="p">anniversary</p>
</td>
<td class="entry" valign="top">
<p class="p">5 and 10 days</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is within the next</p>
</td>
<td class="entry" valign="top">
<p class="p">anniversary</p>
</td>
<td class="entry" valign="top">
<p class="p">10 days</p>
</td>
</tr>
<tr class="row">
<td class="entry" valign="top">
<p class="p">is not within the last</p>
</td>
<td class="entry" valign="top">
<p class="p">anniversary</p>
</td>
<td class="entry" valign="top">
<p class="p">5 days</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>

<div class="example">
<h3 class="title sectiontitle">Example Call Number 1</h3>
</div>

<div class="section">
<h3 class="title sectiontitle"><strong class="ph b">Using Relational Table Criteria</strong></h3>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;CreateQuery&gt;
      &lt;PARENT_LIST_ID&gt;348328&lt;/PARENT_LIST_ID&gt;
      &lt;QUERY_NAME&gt;xli_test_create_Q7&lt;/QUERY_NAME&gt;
      &lt;VISIBILITY&gt;1&lt;/VISIBILITY&gt;
      &lt;CRITERIA&gt;
        &lt;EXPRESSION criteria_type="rt_profile"&gt;
          &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
          &lt;ID&gt;348449&lt;/ID&gt;
          &lt;OPERATOR&gt;match&lt;/OPERATOR&gt;
          &lt;RT_EXPRESSIONS&gt;
            &lt;EXPRESSION criteria_type="rt_profile"&gt;
              &lt;COLUMN&gt;age&lt;/COLUMN&gt;
              &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
              &lt;OPERATOR&gt;is blank&lt;/OPERATOR&gt;
            &lt;/EXPRESSION&gt;
          &lt;/RT_EXPRESSIONS&gt;
        &lt;/EXPRESSION&gt;
      &lt;/CRITERIA&gt;
    &lt;/CreateQuery&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;
</pre>
<p class="p">This criteria creates Editable Criteria:</p>
<p class="p"><strong class="ph b">WHEN</strong></p>
<p class="p">In Relational Table: testRt1</p>
<p class="p"><strong class="ph b">WHEN</strong>&nbsp;age is blank</p>
<div class="section">
<h3 class="title sectiontitle">Example Call Number 2</h3>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;CreateQuery&gt;
      &lt;QUERY_NAME&gt;Females who purchased single item greater than 100&lt;/QUERY_NAME&gt;
      &lt;PARENT_LIST_ID&gt;2740754&lt;/PARENT_LIST_ID&gt;
      &lt;VISIBILITY&gt;1&lt;/VISIBILITY&gt;
      &lt;CRITERIA&gt;
        &lt;EXPRESSION criteria_type="profile"&gt;
          &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
          &lt;PARENS&gt;(&lt;/PARENS&gt;
          &lt;OPERATOR&gt;is equal to&lt;/OPERATOR&gt;
          &lt;COLUMN&gt;Gender&lt;/COLUMN&gt;
          &lt;VALUE&gt;
            &lt;![CDATA[Female]]&gt;
          &lt;/VALUE&gt;
        &lt;/EXPRESSION&gt;
        &lt;EXPRESSION criteria_type="profile"&gt;
          &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
          &lt;OPERATOR&gt;is equal to one of the following&lt;/OPERATOR&gt;
          &lt;COLUMN&gt;Zip Code&lt;/COLUMN&gt;
          &lt;VALUES&gt;
            &lt;VALUE&gt;
              &lt;![CDATA[30318]]&gt;
            &lt;/VALUE&gt;
            &lt;VALUE&gt;
              &lt;![CDATA[30306]]&gt;
            &lt;/VALUE&gt;
            &lt;VALUE&gt;
              &lt;![CDATA[30308]]&gt;
            &lt;/VALUE&gt;
            &lt;VALUE&gt;
              &lt;![CDATA[30314]]&gt;
            &lt;/VALUE&gt;
          &lt;/VALUES&gt;
          &lt;PARENS&gt;)&lt;/PARENS&gt;
        &lt;/EXPRESSION&gt;
        &lt;EXPRESSION criteria_type="relational_table"&gt;
          &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
          &lt;OPERATOR&gt;match&lt;/OPERATOR&gt;
          &lt;ID&gt;9864803&lt;/ID&gt;
          &lt;RT_EXPRESSIONS&gt;
            &lt;EXPRESSION criteria_type="rt_profile"&gt;
              &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
              &lt;OPERATOR&gt;is today&lt;/OPERATOR&gt;
              &lt;COLUMN&gt;Date Purchased&lt;/COLUMN&gt;
            &lt;/EXPRESSION&gt;
            &lt;EXPRESSION criteria_type="rt_profile"&gt;
              &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
              &lt;OPERATOR&gt;is greater than&lt;/OPERATOR&gt;
              &lt;COLUMN&gt;Item Price&lt;/COLUMN&gt;
              &lt;VALUE&gt;
                &lt;![CDATA[100.00]]&gt;
              &lt;/VALUE&gt;
            &lt;/EXPRESSION&gt;
          &lt;/RT_EXPRESSIONS&gt;
        &lt;/EXPRESSION&gt;
      &lt;/CRITERIA&gt;
    &lt;/CreateQuery&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;
</pre>
<p>This would result in a Database Query containing profile criteria and RT criteria</p>
<p>WHEN (Gender is equal to Female<br />AND Zip Code is equal to one of the following (30318 | 30306 | 30308 | 30314))<br />AND<br />Relational Table: Orders<br />Date Purchased is today<br />AND Item Price is greater than 100.00</p>
</div>
<div class="section">
<h3 class="title sectiontitle"><strong class="ph b">When Will this Call Fail?</strong></h3>
<p class="p">This call fails when:</p>
<ul class="ul">
<li class="li">The Call is malformed.</li>
<li class="li">Missing required elements such as the Visibility field.</li>
<li class="li">Query name is already in use.</li>
</ul>
</div>
<div class="section">
<h3 class="title sectiontitle"><strong class="ph b">Example Error Malformed Call and Response</strong></h3>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;CreateQuery&gt;
    &lt;PARENT_LIST_ID&gt;348328&lt;/PARENT_LIST_ID&gt;
    &lt;QUERY_NAME&gt;xli_test_create_Q8&lt;/QUERY_NAME&gt;
    &lt;VISIBILITY&gt;1&lt;/VISIBILITY&gt;
    &lt;CRITERIA&gt;
      &lt;EXPRESSION
        criteria_type="relational_table"&gt;
      &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
      &lt;ID&gt;348449&lt;/ID&gt;
      &lt;OPERATOR&gt;not match&lt;/OPERATOR&gt;
      &lt;RT_EXPRESSIONS&gt;
      &lt;EXPRESSION criteria_type="rt_profile"&gt;
      &lt;COLUMN&gt;age&lt;/COLUMN&gt;
      &lt;CONJUNCTION&gt;AND&lt;/CONJUNCTION&gt;
      &lt;OPERATOR&gt;is blank&lt;/OPERATOR&gt;
      &lt;EXPRESSION&gt;
        &lt;/RT_EXPRESSION&gt;
      &lt;/EXPRESSION&gt;
    &lt;/CRITERIA&gt;
    &lt;CreateQuery&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;
</pre>
<p><strong class="ph b">Response</strong></p>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;RESULT&gt;
      &lt;SUCCESS&gt;false&lt;/SUCCESS&gt;
    &lt;/RESULT&gt;
    &lt;Fault&gt;
      &lt;Request/&gt;
      &lt;FaultCode/&gt;
      &lt;FaultString&gt;Invalid XML Request&lt;/FaultString&gt;
      &lt;detail&gt;
        &lt;error&gt;
          &lt;errorid&gt;51&lt;/errorid&gt;
          &lt;module/&gt;
          &lt;class&gt;SP.API&lt;/class&gt;
          &lt;method/&gt;
        &lt;/error&gt;
      &lt;/detail&gt;
    &lt;/Fault&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;
</pre>
</div>
<div class="section">
<h3 class="title sectiontitle"><strong class="ph b">Example Error Response: Missing Visible Field</strong></h3>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;RESULT&gt;
      &lt;SUCCESS&gt;false&lt;/SUCCESS&gt;
    &lt;/RESULT&gt;
    &lt;Fault&gt;
      &lt;Request/&gt;
      &lt;FaultCode/&gt;
      &lt;FaultString&gt;
        &lt;! [CDATA[ Parameter VISIBILITY was not provided in API call ]]&gt;
      &lt;/FaultString&gt;
      &lt;detail&gt;
        &lt;error&gt;
          &lt;errorid&gt;100&lt;/errorid&gt;
          &lt;module/&gt;
          &lt;class&gt;SP.API&lt;/class&gt;
          &lt;method/&gt;
        &lt;/error&gt;
      &lt;/detail&gt;
    &lt;/Fault&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;
</pre>
</div>
<div class="section">
<h3 class="title sectiontitle"><strong class="ph b">Example Error Message for Query name that exists</strong></h3>
<pre>&lt;Envelope&gt;
  &lt;Body&gt;
    &lt;RESULT&gt;
      &lt;SUCCESS&gt;false&lt;/SUCCESS&gt;
    &lt;/RESULT&gt;
    &lt;Fault&gt;
      &lt;Request/&gt;
      &lt;FaultCode/&gt;
      &lt;FaultString&gt;
        &lt;! [CDATA[ A List With This Name (xli_test_create_Q1 Already Exists. ]]&gt;
      &lt;/FaultString&gt;
      &lt;detail&gt;
        &lt;error&gt;
          &lt;errorid&gt;256&lt;/errorid&gt;
          &lt;module/&gt;
          &lt;class&gt;SP.ListManager&lt;/class&gt;
          &lt;method/&gt;
        &lt;/error&gt;
      &lt;/detail&gt;
    &lt;/Fault&gt;
  &lt;/Body&gt;
&lt;/Envelope&gt;</pre>
</div>
</div>