返回两个表查询后的记录差异
SELECT SALES.SALE_ID as bysale
FROM SALES
WHERE saledate> '2007-08-01 ' and saledate < '2007-09-1 '
共有19882行记录
select distinct(salesproduct.sale_id) as bysalesproduct
from salesproduct,sales
WHERE saledate> '2007-08-01 ' and saledate < '2007-09-1 'and
sales.sale_id=salesproduct.sale_id
共有19879行记录
用什么方法显示差异的3条数据的单号或者详细资料,saleproduct 表不包括日期
[解决办法]
SELECT * FROM SALES
WHERE saledate> '2007-08-01 ' and saledate < '2007-09-1 '
and SALE_ID not in
(
select distinct(salesproduct.sale_id) as bysalesproduct
from salesproduct,sales
WHERE saledate> '2007-08-01 ' and saledate < '2007-09-1 'and
sales.sale_id=salesproduct.sale_id
)