I would like to write an SQL query for intersection between A and B unless B is empty set. For example:
Table A:
| col |
-------
| 1 |
| 2 |
-------
Table B:
| col |
-------
| 2 |
| 3 |
-------
Table B':
| col |
-------
-------
- For A and B, I expect
2(takeBwhich are also contained inA)- e.g.
SELECT * FROM A INTERSECT SELECT * FROM B;orSELECT A.* from A JOIN B ON a.col = b.col;
- e.g.
- For A and B', I expect
1and2(takeAas default ifBis empty)
Do you have any idea?