1. SQL执行顺序
手写:
select distinct
<select_list>
from
<left_table> <join_type>
join <right_table> on <join_conditions>
where
<where_condition>
group by
<group_by_list>
having
<having_conditions>
order by
<order_by_conditions>
limit <limit_number>
机读:
union后的select先执行
select a from t1 union select b from t2;
先执行select b from t2;
from <left_table>
on <join_conditions>
<join_type> join <right_table>
where <where_condition>
group by <group_by_list>
having <having_conditions>
select
distinct <select_list>
order by <order_by_conditions>
limit <limit_number>
2. join图