# Working with Joins - Case Study - Cont'd

+ The last part of the query changed from `TC.col2 = TD.col2` to `TA.col2 = TD.col2` - Not helpful at all.

![`smart`](OptimizerHints06_en_001_20240207.png)

----------------------------------------------------
We modified the SQL query as follows:

```
SELECT COUNT(*) FROM TA, TB, TC, TD WHERE TA.col1 = TB.col1 AND TA.col2 = TC.col2 AND TA.col2 = TD.col2;
```

Even after modifying the SQL query to `WHERE TA.col1 = TB.col1 AND TA.col2 = TC.col2 AND TA.col2 = TD.col2`, the join order remains `TA`-`TB`-`TC`-`TD`. This is primarily because the `HashJoin` operator does not account for the data distribution between the two tables when estimating the result set, leading to a discrepancy between the `estRows` and `actRows` in the optimizer.