A
ID | N | EN |
1 | A1 | 1 |
2 | A2 | 1 |
3 | A3 | 0 |
10 | A10 | 1 |
11 | A11 | 0 |
|
|
|
B
ID | N | EN |
2 | B2 | 0 |
3 | B3 | 1 |
5 | B5 | 1 |
10 | B10 | 1 |
11 | B11 | 0 |
|
|
|
1.
SELECT * FROM A
LEFT JOIN B
ON A.ID = B.ID
ID | N | EN | ID | N | EN |
1 | A1 | 1 | NULL | NULL | NULL |
2 | A2 | 1 | 2 | B2 | 0 |
3 | A3 | 0 | 3 | B3 | 1 |
10 | A10 | 1 | 10 | B10 | 1 |
11 | A11 | 0 | 11 | B11 | 0 |
2.
SELECT * FROM A
LEFT JOIN B
ON A.ID = B.ID
AND A.EN = 1
AND B.EN = 1
ID | N | EN | ID | N | EN |
1 | A1 | 1 | NULL | NULL | NULL |
2 | A2 | 1 | NULL | NULL | NULL |
3 | A3 | 0 | NULL | NULL | NULL |
10 | A10 | 1 | 10 | B10 | 1 |
11 | A11 | 0 | NULL | NULL | NULL |
3.
SELECT * FROM A
LEFT JOIN B
ON A.ID = B.ID
WHERE A.EN = 1
AND B.EN = 1
ID | N | EN | ID | N | EN |
10 | A10 | 1 | 10 | B10 | 1 |
4.
ID | N | EN | ID | N | EN |
10 | A10 | 1 | 10 | B10 | 1 |
5.
SELECT * FROM A
LEFT JOIN B
ON A.ID = B.ID
AND B.EN = 1
WHERE A.EN = 1
ID | N | EN | ID | N | EN |
1 | A1 | 1 | NULL | NULL | NULL |
2 | A2 | 1 | NULL | NULL | NULL |
10 | A10 | 1 | 10 | B10 | 1 |