日期:2014-05-18 浏览次数:20571 次
insert tb1 select MarketId, StockId, NewPrice from tb2 a where not exists(select 1 from tb1 a where a.MarketId=b.MarketId and a.StockId=b.StockId)
------解决方案--------------------
insert into tb1 (MarketId, StockId, NewPrice) select MarketId, StockId, NewPrice from tb2 where not ( MarketId in (select MarketId from tb1) and StockId in (Select StockId from tb1)) --这句错了 insert into tb1 (MarketId, StockId, NewPrice) select MarketId, StockId, NewPrice from tb2 where MarketId not in(select MarketId from tb2) and StockId not in(select StockId from tb2) --这样写可以,但是逻辑上有问题,还是用exists的吧