I have a SQL statement I'm running in mySQL and it is stalling. I've narrowed it down to the NOT EXISTS subquery. Can you help me figure out what went wrong?
I'm trying to get data from piewarehouse filtered for pieIDs that were not refilled that day.
SELECT * FROM piewarehouse PW
inner join toiletpaper TP on TP.tpid = PW.pieid
where TP.rolltype in ('long', 'short', 'sheet')
and (not exists (select 1 from piewarehouse PW2 where PW2.pieID = PW.pieid and PW2.daterefilled = '2013-06-12'))