# Working with Joins - Sample Schema Setup - Cont'd

```
tidb>SELECT COUNT(*) FROM TA;
+----------+
| COUNT(*) |
+----------+
|   1000   |
+----------+
1 row in set (0.01 sec)

tidb>SELECT COUNT(*) FROM TB;
+----------+
| COUNT(*) |
+----------+
|   1200   |
+----------+
1 row in set (0.00 sec)

tidb>SELECT COUNT(*) FROM TC;
+----------+
| COUNT(*) |
+----------+
|   1500   |
+----------+
1 row in set (0.00 sec)

tidb>SELECT COUNT(*) FROM TD;
+----------+
| COUNT(*) |
+----------+
|   2000   |
+----------+
1 row in set (0.01 sec)
```
```
tidb>SELECT COUNT(DISTINCT(col1)) FROM TA;
+-----------------------+
| COUNT(DISTINCT(col1)) |
+-----------------------+
|         100           |
+-----------------------+
1 row in set (0.00 sec)

tidb>SELECT COUNT(DISTINCT(col2)) FROM TA;
+-----------------------+
| COUNT(DISTINCT(col2)) |
+-----------------------+
|         100           |
+-----------------------+
1 row in set (0.01 sec)

tidb>SELECT COUNT(DISTINCT(col1)) FROM TB;
+-----------------------+
| COUNT(DISTINCT(col1)) |
+-----------------------+
|         100           |
+-----------------------+
1 row in set (0.01 sec)

tidb>SELECT COUNT(DISTINCT(col2)) FROM TC;
+-----------------------+
| COUNT(DISTINCT(col2)) |
+-----------------------+
|         100           |
+-----------------------+
1 row in set (0.01 sec)

tidb>SELECT COUNT(DISTINCT(col2)) FROM TD;
+-----------------------+
| COUNT(DISTINCT(col2)) |
+-----------------------+
|         101           |
+-----------------------+
1 row in set (0.00 sec)
```
```
tidb>SELECT COUNT(*) FROM TA JOIN TB ON(TA.col1=TB.col1);
+----------+
| COUNT(*) |
+----------+
|  12000   |
+----------+
1 row in set (0.01 sec)

tidb>SELECT COUNT(*) FROM TA JOIN TC ON(TA.col2=TC.col2);
+----------+
| COUNT(*) |
+----------+
|  15000   |
+----------+
1 row in set (0.00 sec)

tidb>SELECT COUNT(*) FROM TC JOIN TD ON(TC.col2=TD.col2);
+----------+
| COUNT(*) |
+----------+
|    15    |
+----------+
1 row in set (0.01 sec)

tidb>SELECT COUNT(*) FROM TA JOIN TD ON(TA.col2=TD.col2);
+----------+
| COUNT(*) |
+----------+
|    10    |
+----------+
1 row in set (0.01 sec)
```

------------------------------------------------------------------------------
We found that tables `TA`, `TB`, `TC`, and `TD` have 1000 rows, 1200 rows, 1500 rows, and 2000 rows respectively. The selectivity of column `col1` and `col2` in table `TA` is 1/100 each, the selectivity of column `col1` in table `TB` is 1/100, the selectivity of column `col2` in table `TC` is 1/100, and the selectivity of column `col2` in table `TD` is 1/100.

When `TA` and `TB` are joined based on `TA.col1 = TB.col1`, the resulting set consists of 12,000 rows. Similarly, joining `TA` and `TC` based on `TA.col2 = TC.col2` yields a result set of 15,000 rows. The join between `TC` and `TD` on `TC.col2 = TD.col2` results in 15 rows, while the join between `TA` and `TD` based on `TA.col2 = TD.col2` results in 10 rows.

Next, we will discuss the process of joining these four tables together.