querybuilder
querybuilder copied to clipboard
Unable to provide explicit precedence on combinations such as UNION and INTERSECT
It does not seem to be possible to be explicit about the precedence when applying more than one combination.
In the example below, without the additional parentheses the INTERSECT
will take precedence over the UNION
.
(SELECT 1
UNION
SELECT 2)
INTERSECT
SELECT 2
Is there a way to workaround this issue and add parentheses as needed to enforce the desired precedence?
I'm having the same issue
Not 100% identical but with subqueries you can achieve the same result
var query =
new Query().From(
new Query("A").Union(new Query("B")).As("U1")
).Intersect(new Query("C"));
Will output
SELECT * FROM (SELECT * FROM [A] UNION SELECT * FROM [B]) AS [U1] INTERSECT SELECT * FROM [C]