# Support Recursive Common Table Expressions (CTE)

**URL:** <https://www.singlestore.com/forum/t/support-recursive-common-table-expressions-cte/2326>\
**Category:** Feedback\
**Created:** [September 2, 2020, 8:37pm UTC](https://www.singlestore.com/forum/t/support-recursive-common-table-expressions-cte/2326 "2020-09-02T20:37:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![roxannapourzand](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/r/53a042/32.png) [@roxannapourzand](https://www.singlestore.com/forum/u/roxannapourzand)\
**Post date:** [September 2, 2020, 8:37pm UTC](https://www.singlestore.com/forum/t/support-recursive-common-table-expressions-cte/2326/1 "2020-09-02T20:37:07Z")

</div>

A recursive common table expression (CTE) is a CTE that references itself. The CTE repeatedly executes, returns subsets of data, until it returns the complete result set.

A recursive CTE is useful in querying hierarchical data such as organization charts where one employee reports to a manager and each component itself also consists of many other components.

You can work around this in MemSQL today, but it takes a lot of extra code to do so.

_Note: A member of the MemSQL team has filed this feature request. We are adding in several features to this forum that we believe are popular with our users to engage and better understand the needs of the MemSQL community._

---

<div class="post-metadata">

**Author:** ![christoph](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/c/eb8c5e/32.png) [@christoph](https://www.singlestore.com/forum/u/christoph)\
**Post date:** [August 9, 2022, 9:18pm UTC](https://www.singlestore.com/forum/t/support-recursive-common-table-expressions-cte/2326/2 "2022-08-09T21:18:32Z")

</div>

I would also very much like to see this supported as missing triggers and missing recursive CTEs are the two reasons why we can’t run our application database on SingleStore yet.

---

<div class="post-metadata">

**Author:** ![hanson](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/hanson/32/196_2.png) [@hanson](https://www.singlestore.com/forum/u/hanson)\
**Post date:** [November 18, 2022, 5:11pm UTC](https://www.singlestore.com/forum/t/support-recursive-common-table-expressions-cte/2326/3 "2022-11-18T17:11:25Z")

</div>

The latest release candidate build of 8.0 supports recursive CTEs. See the announcement about the 8.0 RC. Feedback is appreciated.

---

<div class="post-metadata">

**Author:** ![zurab](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/z/c68b51/32.png) [@zurab](https://www.singlestore.com/forum/u/zurab)\
**Post date:** [January 8, 2023, 4:22pm UTC](https://www.singlestore.com/forum/t/support-recursive-common-table-expressions-cte/2326/4 "2023-01-08T16:22:19Z")

</div>

Hello  
I use 8 version  
But sometimes i got error

Unsupported recursive common table expression query shape: Recursive CTE depends on a streaming result table outside of the dependency cycle.

The most interesting thing is that i don’t change my query, i only update value in this table to any value after this, i return to initial value. And my query become to work

But if connect to db with new client, I got this error again

---

<div class="post-metadata">

**Author:** ![hanson](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/hanson/32/196_2.png) [@hanson](https://www.singlestore.com/forum/u/hanson)\
**Post date:** [January 11, 2023, 1:46am UTC](https://www.singlestore.com/forum/t/support-recursive-common-table-expressions-cte/2326/5 "2023-01-11T01:46:00Z")

</div>

The 8.0.5 patch for 8.0 makes that case work.

> **[Maintenance Release Changelog · SingleStore Documentation](https://docs.singlestore.com/db/v8.0/release-notes/singlestoredb-memsql/8-0-release-notes/maintenance-release-changelog/)**
>
> SingleStore is a modern relational database for cloud and on-premises that delivers immediate insights for modern applications and analytical systems. Book a demo or trial today!
