SQL where条件和jion on条件的详解及区别

网络编程 2021-07-05 13:43www.168986.cn编程入门
这篇文章主要介绍了SQL where条件和jion on条件的详解及区别的相关资料,这里举例说明该如何区分,需要的朋友可以参考下

sql 语句中where条件和jion on条件的区别

与有很大的差别,请注意!

SELECT TBL_SchemaDetail.MaterialNo, TBL_StockMaterial.SalePrice 
FROM TBL_StockMaterial RIGHT OUTER JOIN 
   TBL_SchemaDetail ON 
   TBL_StockMaterial.MaterialNo = TBL_SchemaDetail.MaterialNo AND 
   TBL_SchemaDetail.SchemaNo = '7411' AND TBL_StockMaterial.SalePrice = 0 

条件全部放到join的on中。

SELECT TBL_SchemaDetail.MaterialNo, TBL_StockMaterial.SalePrice 
FROM TBL_StockMaterial RIGHT OUTER JOIN 
   TBL_SchemaDetail ON 
   TBL_StockMaterial.MaterialNo = TBL_SchemaDetail.MaterialNo 
WHERE (TBL_SchemaDetail.SchemaNo = '7411') AND (TBL_StockMaterial.SalePrice = 0) 

连接和条件分开。

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by