SELECT
t.*, i.locationhistory
FROM
(SELECT
s.invoice,
o.action,
s.productcode,
s.option1 AS size,
REPLACE(s.serialnumber, 's', '') serialnumber
FROM
(SELECT
action, shipmentids, notes, changedate
FROM
orderchangelog
WHERE
action = 'cant find'
AND DATE(changedate) >= '2022-02-27') o
JOIN shipment s ON o.shipmentIDs = s.shipmentID
WHERE
ordertype = '20'
AND extrastatus = 'partial pending') t
JOIN
inventoryitem i ON i.serialnumber = t.serialnumber
HAVING (i.locationhistory LIKE '%sellable photo studio%'
OR i.locationhistory LIKE '%trucktowarehouse - newarrivals%')