You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(from e in scott.depts yield e.deptno)
except
(from d in scott.depts yield d.deptno)
Example 2:
from deptno in (
(from e in scott.depts yield e.deptno)
union
(from d in scott.depts yield d.deptno))
group compute sum of deptno
Should these operators eliminate duplicates? Most convenient would be if union did not eliminate duplicates (like SQL UNION ALL), effectively treating left and right sides as lists, and if intersect and except treated left side as a list and right side as a set (somewhat like SQL INTERSECT ALL and EXCEPT ALL).
If people want to eliminate duplicates afterwards, they can enclose in from x in (...) group x.
The text was updated successfully, but these errors were encountered:
union and except have the same precedence as + and -; intersect has the same precedence as *. This is consistent with SQL (although the SQL set operators never apply to scalar expressions).
The precedence is higher than in SQL, which means that occasionally you use parentheses where you would not in SQL. In particular, the case from ... yield union from ....
These are more 'list' operators than 'set' operators:
union acts like SQL UNION ALL, preserving duplicates on both sides;
intersect and except preserve duplicates on the left side, but unlike SQL INTERSECT ALL and EXCEPT ALL they keep/remove every occurrence of an element on the left side if there are any occurrences of the element on the right side.
In relational.sml, I added some examples that simulate SQL's INTERSECT ALL, EXCEPT DISTINCT, etc.
Add
union
,intersect
,minus
query operators.Example 1:
Example 2:
Should these operators eliminate duplicates? Most convenient would be if
union
did not eliminate duplicates (like SQLUNION ALL
), effectively treating left and right sides as lists, and ifintersect
andexcept
treated left side as a list and right side as a set (somewhat like SQLINTERSECT ALL
andEXCEPT ALL
).If people want to eliminate duplicates afterwards, they can enclose in
from x in (...) group x
.The text was updated successfully, but these errors were encountered: