A – ( B ∩ A )
I was wondering what this set of mathematics can translate to when looking at,comparing it with SQL (operators).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If
AandBare tables of the same “type” (same number of columns and compatible datatypes on corresponding columns), this can be translated to SQL like this:which is of course equivalent (both in set and relational algebra) to:
If
AandBare tables of different “type”, then set operations do not make sense between them. (Joins are something different, they should not be confused with Unions, Differences or Intersections, no matter how popular a link that “explains” them is.)The fact that Unions, Differences and Intersections can also be expressed in several ways (using
(LEFT) JOIN,(NOT) IN,(NOT) EXISTScombinations, besides the explicitUNION,EXCEPTandINTERSECToperators) does not change that.The syntax is not exactly as above. One can use either (works in Postgres and SQL-Server. It also works in Oracle if one replaces
EXCEPTwithMINUS):or this (works in Postgres 8.4 and above: SQL-Fiddle test)
and even this (Look ma, no
SELECT!):