日期:2014-05-18 浏览次数:20570 次
select Insert_SingleNumber as 所属订单,Insert_GoodsName as 货物名称,Insert_GoodsModel as 规格型号,Insert_GoodsUnit as 单位,Insert_GoodsPrice as 单价,Insert_GoodsAmount as 数量 from MIS_InsertInfo , MIS_Single where InsertInfo.Insert_SingleNumber = MIS_Single.Single_Number and MIS_Single.Single_Number=321
------解决方案--------------------
貌似你后面那个表没什么用处,可直接更改为如下:
select Insert_SingleNumber as 所属订单,Insert_GoodsName as 货物名称,Insert_GoodsModel as 规格型号,Insert_GoodsUnit as 单位,Insert_GoodsPrice as 单价,Insert_GoodsAmount as 数量 from MIS_InsertInfo where Insert_SingleNumber = 321
------解决方案--------------------
in 的效率比较低,大数据量的话查询很慢
建议用exists
select Insert_SingleNumber as 所属订单,Insert_GoodsName as 货物名称,Insert_GoodsModel as 规格型号, Insert_GoodsUnit as 单位,Insert_GoodsPrice as 单价,Insert_GoodsAmount as 数量 from MIS_InsertInfo where exists (select Single_Number from MIS_Single where Single_Number=321 and MIS_InsertInfo.Insert_SingleNumber = MIS_Single.Single_Number)