If A is a proper subset of B or vice versa, then the query should return true. if not, then false:
This is the code to create table A and table B:
Create table A (i int);
Create table B (i int);
Insert into A values (1);
Insert into A values (2);
Insert into A values (3);
Insert into B values (2);
Insert into B values (3);
Insert into B values (6);
This is the code that i wrote:
SELECT Count(*) >= 1
FROM A
RIGHT JOIN B ON A=B
WHERE A IS NULL;
I get a true, but it should be a false.
Does anybody know what is wrong with my code?
I understand you want the query to check if either A is proper subset of A, or if B is a proper subset of A (both cannot be true at the same time).
A ⊂ B
reads as: every element ofA
can be found inB
, and not all elements ofB
exist inA
.In SQL this would be a
full join
and conditional logic: