---
title: R2 SQL now supports UNION, INTERSECT, EXCEPT, and SELECT DISTINCT
description: Combine query results with set operations and eliminate duplicates with SELECT DISTINCT.
image: https://edgetunnel-b2h.pages.dev/changelog-preview.png
---

> Documentation Index  
> Fetch the complete documentation index at: https://edgetunnel-b2h.pages.dev/changelog/llms.txt  
> Use this file to discover all available pages before exploring further. 

[Skip to content](#%5Ftop) 

# Changelog

New updates and improvements at Cloudflare.

[ Subscribe to RSS ](https://edgetunnel-b2h.pages.dev/changelog/rss/index.xml) [ View RSS feeds ](https://edgetunnel-b2h.pages.dev/fundamentals/new-features/available-rss-feeds/) 

![hero image](https://edgetunnel-b2h.pages.dev/_astro/hero.CVYJHPAd_26AMqX.svg) 

[ ← Back to all posts ](https://edgetunnel-b2h.pages.dev/changelog/) 

## R2 SQL now supports UNION, INTERSECT, EXCEPT, and SELECT DISTINCT

Jun 08, 2026 

[ R2 SQL ](https://edgetunnel-b2h.pages.dev/r2-sql/) 

[R2 SQL](https://edgetunnel-b2h.pages.dev/r2-sql/) now supports set operations (`UNION`, `INTERSECT`, `EXCEPT`) and `SELECT DISTINCT`, expanding the range of analytical queries you can run directly on [Apache Iceberg ↗](https://iceberg.apache.org/) tables in [R2 Data Catalog](https://edgetunnel-b2h.pages.dev/r2/data-catalog/).

#### Set operations

Combine the results of multiple `SELECT` statements:

* **`UNION`** — returns all rows from both queries, removing duplicates
* **`UNION ALL`** — returns all rows from both queries, including duplicates
* **`INTERSECT`** — returns only rows that appear in both queries
* **`EXCEPT`** — returns rows from the first query that do not appear in the second

```sql
-- Find zones that had either firewall blocks OR high-risk requests
SELECT zone_id FROM my_namespace.firewall_events WHERE action = 'block'
UNION
SELECT zone_id FROM my_namespace.http_requests WHERE risk_score > 0.8
```

```sql
-- Find zones with both firewall blocks AND high traffic
SELECT zone_id FROM my_namespace.firewall_events WHERE action = 'block'
INTERSECT
SELECT zone_id FROM my_namespace.http_requests
GROUP BY zone_id
HAVING COUNT(*) > 10000
```

```sql
-- Find enterprise zones that have not been compacted
SELECT zone_id FROM my_namespace.zones WHERE plan = 'enterprise'
EXCEPT
SELECT zone_id FROM my_namespace.compaction_history
```

#### Select distinct

Eliminate duplicate rows from query results:

```sql
SELECT DISTINCT region, department
FROM my_namespace.sales_data
WHERE total_amount > 1000
ORDER BY region, department
LIMIT 100
```

For large datasets where approximate results are acceptable, `approx_distinct()` remains a faster alternative for counting unique values.

For the full syntax reference, refer to the [SQL reference](https://edgetunnel-b2h.pages.dev/r2-sql/sql-reference/). For performance guidance, refer to [Limitations and best practices](https://edgetunnel-b2h.pages.dev/r2-sql/reference/limitations-best-practices/).

```json
{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://edgetunnel-b2h.pages.dev/changelog/post/2026-06-05-union-intersect-except-select-distinct/#page","headline":"R2 SQL now supports UNION, INTERSECT, EXCEPT, and SELECT DISTINCT · Changelog","description":"Combine query results with set operations and eliminate duplicates with SELECT DISTINCT.","url":"https://edgetunnel-b2h.pages.dev/changelog/post/2026-06-05-union-intersect-except-select-distinct/","inLanguage":"en","image":"https://edgetunnel-b2h.pages.dev/changelog-preview.png","dateModified":"2026-06-08","datePublished":"2026-06-08","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://edgetunnel-b2h.pages.dev/#website","name":"Cloudflare Docs","url":"https://edgetunnel-b2h.pages.dev/"}}
```
