Left Outer Join doesn't return all rows from my left table?

后端 未结 3 1979
陌清茗
陌清茗 2020-11-21 10:23

I am trying to get the number of page opens on a per day basis using the following query.

SELECT day.days, COUNT(*) as opens 
FROM day 
LEFT OUTER JOIN track         


        
3条回答
  •  后悔当初
    2020-11-21 10:37

    The condition is in the WHERE clause. After joining the tables the WHERE conditions are evaluated to filter out everything matching the criteria.Thus anything not matching tracking.open_id = 10 gets discarded.

    If you want to apply this condition while joining the two tables, a better way is to use it with the ON clause (i.e. joining condition) than the entire dataset condition.

提交回复
热议问题