Why MySQL's LEFT JOIN is returning “NULL” records when with WHERE clause?

前端 未结 4 637
野性不改
野性不改 2021-02-01 09:39

Today I\'ve tried some more complex MySQL queries and I\'ve noticed that MySQL\'s LEFT JOIN is not working with WHERE clause. I mean, it does return some records but it does not

4条回答
  •  轮回少年
    2021-02-01 10:30

    First Case :

    After joining, the records are getting filtered by the (WHERE clause). So only 1 result.

    Second Case (when you replace WHERE with AND)

    Will return all join entries + entries satisfied in second condition (t2.rank != 17). That is why here you get 2 records ( one from join + another from AND clause)

提交回复
热议问题