AND QBE Operator

Learn to use the _and QBE operator to filter specific data from the car racing dataset through simple examples.

To perform a logical AND operation between two or more predicates, you can enclose each of the predicate in the curly braces, and provide them as values to an array for the _and operator.

Example 3-16 _and Operator

SELECT JSON_SERIALIZE(data PRETTY) AS data FROM GRAPHQL('
    query {
        team (
            check: {
                _and: [
                    {name: {_like: "%Mercedes%"}},
                    {points: {_gt: 300}}
                ]
            }
        ) {
            id: team_id
            name
            points
        }
    }
');

In the preceding code example, the specified details of the team table are retrieved only when the two conditions specified in the _and clause are met. In this case, the team’s name must contain the string “Mercedes” and then the value of the points field must be greater than 300.

DATA
--------------------------------------------------------------------------------
{
  "id" : 301,
  "name" : "McLaren Mercedes",
  "points" : 666
}

{
  "id" : 304,
  "name" : "Mercedes",
  "points" : 468
}


2 rows selected.