# NOT keyword in CQL (Confluence): syntax and examples

URL: https://goingstellar.ro/reference/cql/not-keyword/

NOT negates a clause that comes after it, or a whole group in parentheses. Use it for conditions that have no negative operator, or to flip an OR group in one step instead of rewriting each clause.

## Syntax

```
clause1 AND NOT clause2
clause1 and not (clause2 or clause3)
```

## Arguments

- `clause` (optional: yes): A CQL clause, or several clauses in parentheses.

## Works with

- Operators: negates a clause with any operator, including ~ and IN.
- Functions: any function inside the negated clause.
- Not with: the start of a query, and a clause with no AND or OR before it.

## Examples

```
type = page and not space = SD
```

Finds pages that live outside one space. Run on Confluence Cloud on 2026-11-29.

```
type = page and not title ~ "template"
```

Removes template pages from a page list without a !~ clause. Run on Confluence Cloud on 2026-11-29.

```
type = page and space = SD and not (title ~ "template" or title ~ "policy")
```

Excludes two kinds of page with one negation by grouping them. Run on Confluence Cloud on 2026-11-29.

```
space = SD and not type = attachment
```

Keeps everything in a space except uploaded files. Run on Confluence Cloud on 2026-11-29.

```
label = cql and not space = SD
```

The documentation example, with a space key that exists. Finds labelled pages that are not in the space. Run on Confluence Cloud on 2026-11-29.

## Pitfalls

- NOT cannot start a query. `not space = SD` fails with "Could not parse cql". Put a positive clause first and join with AND, as in `type = page and not space = SD` (checked on Confluence Cloud, November 2026).
- NOT still needs a joiner. `type = page and space = SD not title ~ "template"` fails with the same parse error. Write `and not`.
- Case does not matter. `not`, `NOT` and `Not` all run (checked on Confluence Cloud, November 2026), so the lowercase form in the Atlassian example is valid.
- For simple cases the negative operators read better: `!=`, `!~` and `NOT IN` need no extra keyword.

## Related

- [AND](https://goingstellar.ro/reference/cql/and-keyword/)
- [OR](https://goingstellar.ro/reference/cql/or-keyword/)
- [!=](https://goingstellar.ro/reference/cql/not-equals-operator/)
- [NOT IN](https://goingstellar.ro/reference/cql/not-in-operator/)
- [!~](https://goingstellar.ro/reference/cql/does-not-contain-operator/)
- [Reserved characters and words](https://goingstellar.ro/reference/cql/reserved-words/)

## Sources

- [CQL keywords (Atlassian Developer, Confluence Cloud)](https://developer.atlassian.com/cloud/confluence/cql-keywords/)

