27,582
社区成员




select a.a,a.b.a.c from a inner join f on a.id=f.id where a.c>0 and a.b like 'E%'
select a.a,a.b.a.c from a inner join f on a.id=f.id where a.c>0 where a.b like 'E%'
select * from (
select a.a,a.b.a.c from a inner join f on a.id=f.id where a.c>0 ) temp where b like 'E%'
楼主测试下。
条件写的位置不对,不是连接条件,是过滤条件。。。SQL Select语句完整的执行顺序:
1、from子句组装来自不同数据源的数据;
2、where子句基于指定的条件对记录行进行筛选;
3、group by子句将数据划分为多个分组;
4、使用聚集函数进行计算;
5、使用having子句筛选分组;
6、计算所有的表达式;
7、使用order by对结果集进行排序。
另外:一个查询语句各个部分的执行顺序:
--8) SELECT (9) DISTINCT (11) <TOP_specification> <select_list>
--(1) FROM <left_table>
--(3) <join_type> JOIN <right_table>
--(2) ON <join_condition>
--(4) WHERE <where_condition>
--(5) GROUP BY <group_by_list>
--(6) WITH {CUBE | ROLLUP}
--(7) HAVING <having_condition>
--(10) ORDER BY <order_by_list>
看一看SQL 语句执行的顺序你就知道了啥