日期:2014-05-16  浏览次数:20759 次

请教一条SQL语句
入库表IN(产品ID字段PID,入库数InNum)  
出库表OUT(产品ID字段PID,出库数OutNum)  

现在我想查询入库表的信息,并且库存(入库数-出库数)大于10的信息,请教!

------解决方案--------------------
drop table if exists tmp_ruku_ids;
create table tmp_ruku_ids as SELECT ruke.pid FROM ruku r INNER JOIN chuku c ON r.PID=c.PID WHERE r.InNum-c.OutNum >3;
SELECT * FROM ruku WHERE pid in(select pid from tmp_ruku_ids );