单条命令执行
1.select wo.*,batch-sum(de.capacity) from worder wo,details de where wo.line=132 and wo.finish='no' and wo.workorder=de.workorder
执行结果:
2.select worder.*,batch from worder where line=12 and finish='no' and workorder not in(select workorder from details group by workorder)
执行结果:
联合查询
select wo.*,batch-sum(de.capacity) from worder wo,details de where wo.line=12 and wo.finish='no' and wo.workorder=de.workorder
union all
select worder.*,batch from worder where line=12 and finish='no' and workorder not in(select workorder from details group by workorder)
执行结果:
联合查询 union all 不是对这两行的结果进行简单组合吗,这是怎么一回事?
1.select wo.*,batch-sum(de.capacity) from worder wo,details de where wo.line=132 and wo.finish='no' and wo.workorder=de.workorder
执行结果:
2.select worder.*,batch from worder where line=12 and finish='no' and workorder not in(select workorder from details group by workorder)
执行结果:
联合查询
select wo.*,batch-sum(de.capacity) from worder wo,details de where wo.line=12 and wo.finish='no' and wo.workorder=de.workorder
union all
select worder.*,batch from worder where line=12 and finish='no' and workorder not in(select workorder from details group by workorder)
执行结果:
联合查询 union all 不是对这两行的结果进行简单组合吗,这是怎么一回事?
select wo.*,batch-sum(de.capacity) from worder wo,details de where wo.line=12 and wo.finish='no' and wo.workorder=de.workorder) A
union all
SELECT * FROM (
select worder.*,batch from worder where line=12 and finish='no' and workorder not in(select workorder from details group by workorder))B
1.的查询结果是空的,
2.的查询结果是一条,然而进行联合查询时。就应该返回的是
2.的这一条查询的结果呀,为何它还返回了上一行,很奇怪的一行,只有line有值,而且line 值根本就不是我限定的12.(我限定的是12 呀。)
select wo.*,batch-sum(de.capacity) from worder wo,details de where wo.line=12 and wo.finish='no' and wo.workorder=de.workorder2.代表查询
select worder.*,batch from worder where line=12 and finish='no' and workorder not in(select workorder from details group by workorder
aaaa 等级:
结帖率:100% 21321
#2 得分:0 回复于: 2012-12-11 08:32:56
详细说明,试试SELECT * FROM (
select wo.*,batch-sum(de.capacity) from worder wo,details de where wo.line=12 and wo.finish='no' and wo.workorder=de.workorder) A
union all
SELECT * FROM (
select worder.*,batch from worder where line=12 and finish='no' and workorder not in(select workorder from details group by workorder))B