where 与 having 的区别

where是对数据直接处理,having是对产生的结果再进行处理

 

select goods_id,goods_name,market_price-shop_price  as k from goods where market_price-shop_price >200;

上语句只能使用

where market_price-shop_price>200  而不能使用 where k >200;

 

 

但是对于having 来说如下

select goods_id,goods_name,market_price-shop_price  as k from goods having k >200;
posted @ 2013-11-22 23:40  long896130895  阅读(179)  评论(0)    收藏  举报