In MySQL queries, why use join instead of where?

前端 未结 6 728
孤独总比滥情好
孤独总比滥情好 2020-11-22 17:34

It seems like to combine two or more tables, we can either use join or where. What are the advantages of one over the other?

6条回答
  •  -上瘾入骨i
    2020-11-22 17:53

    Actually you often need both "WHERE" and "JOIN".

    "JOIN" is used to retrieve data from two tables - based ON the values of a common column. If you then want to further filter this result, use the WHERE clause.

    For example, "LEFT JOIN" retrieves ALL rows from the left table, plus the matching rows from the right table. But that does not filter the records on any specific value or on other columns that are not part of the JOIN. Thus, if you want to further filter this result, specify the extra filters in the WHERE clause.

提交回复
热议问题