用SQL查没有销售记录的商品
发布网友
发布时间:2023-08-02 17:21
我来回答
共1个回答
热心网友
时间:2024-12-04 05:31
查出06-07年没有销售记录的产品并插入到deleteDate表里
注意deleteDate表的列和PRODUCTS表的列是否一致
insert into deleteDate
select a.* from procts a
where ProctID not in(
select ProctID from OrderDetails a
inner join order b on a.orderid=b.orderid
where b.orderdate between '2006-01-01' and '2007-12-31'
group by ProctID
)
delete from Procts
where ProctID in(
select ProctID from deleteDate
)