Set operations kya hoti hain?

Set operations = multiple SELECT results ko “vertically” combine karna.

Matlab rows ko upar-neeche stack karna.

Socho:

Table1 ka result + Table2 ka result → ek final result set.

✅ Set ops = row-wise combination

✅ Joins = column-wise combination


1) “Always gives distinct rows” — correction

Notes me likha hai “Always distinct.”

✅ Ye UNION ke liye true hai, but set ops me 2 versions hoti hain:

INTERSECT / EXCEPT typically distinct behavior rakhte, but DBs me ALL variants bhi kabhi-kabhi milte hain.


2) UNION

Meaning

Do ya zyada SELECT results ko merge (stack) karna, duplicates hata ke.

SELECT*FROM table1
UNION
SELECT*FROM table2;

Rules (very important)