比如我有一个sql查询:
select table1.*, table2.* from table1
left join table2 on table1.id=table2.id AND table2.someCol>123 (put it here)<p>
where table2.someCol>123 (or put it here)
好像这两个位置都可以放过滤条件,而且是同一个意思吧?
最佳答案
不,这不一样。当您左/右加入时很重要。如果您在引用左连接表或右连接表的 where 子句中放置一个 where 条件,您基本上会将它变成一个内部连接。如果您添加 OR referenced_left_or_right_joined_column IS NULL
,它将再次成为左连接或右连接。
关于mysql - SQL 连接语法 : put data filter in "on clause" or "where clasuse"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23222579/