Quantcast
Viewing all articles
Browse latest Browse all 207

String manipulation in Recursive CTE

I am trying to make something like the following work:

WITH results(n, string ) AS (            SELECT 1,'lol'            UNION ALL            SELECT n+1, string +' lol'            FROM results            WHERE n<6            )            SELECT * FROM results

But SQL doesn't seem to recognize the string concatenation in the second column and returns the error:

Types don't match between the anchor and the recursive part in column "string" of recursive query "results".

My desired output would be something like

1, lol

2, lol lol

3, lol lol lol

and so on


Viewing all articles
Browse latest Browse all 207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>