Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSQLrecursive CTEsSingle-choice MCQ

A recursive CTE has the structure below. What is the role of UNION ALL versus UNION here, and the consequence of choosing one?

WITH RECURSIVE r AS ( SELECT n FROM seed UNION ALL SELECT n + 1 FROM r WHERE n < 5 ) SELECT * FROM r;