您的位置:首页 > 数据库 > MySQL

mysql 语句执行顺序

2016-09-25 22:47 351 查看
select[distinct]  
from  
join(如left join)  
on  
where  
group by  
having  
union  
order by  
limit 

select distinct sum(a.OrderPrice) As order1,sum(d.OrderPrice) As order2  
from orders a  
left join (select c.* from Orders c) d   
on a.O_Id = d.O_Id  
where a.Customer='Bush' or a.Customer = 'Adams' or a.Customer = 'Carter'  
group by a.Customer  
having sum(a.OrderPrice) > 1500  
union  
select distinct sum(a.OrderPrice) As order1,sum(e.OrderPrice) As order2  
from orders a  
left join (select c.* from Orders c) e   
on a.O_Id = e.O_Id  
where a.Customer='Bush' or a.Customer = 'Adams' or a.Customer = 'Carter'  
group by a.Customer  
having sum(a.OrderPrice) > 2000  
order by order1  
limit 1 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: