SELECT * FROM IN_ITEMBOMROUTING WHERE PRODUCED_ITEM_ID='000000102001001608'; --BOM and item not in IN_ITEMBOMROUTING SELECT * FROM TEMP_REMOVED_IN_DATA WHERE TABLE_NAME='IN_MO' AND DATA_ID LIKE '%001201191645%' ORDER BY REMOVED_DATE DESC; --BOM and item not in IN_ITEMBOMROUTING SELECT MO_ID, ITEM_ID, BOM_ID, ROUTING_ID, SITEID, SO_ID, SO_LINE_ID, PEGGED_MO_ID, PLANNED_QTY, CREATION_DATETIME, PLANNED_START_DATE, PLANNED_END_DATE, EXT_FORDATE, EXT_FORQTY, EXT_FORTEXT1, EXT_FORTEXT2, EXT_FORTEXT3, MO_TYPE, SOFT_LOCKED FROM IN_MO MO WHERE NOT EXISTS (SELECT NULL FROM IN_ITEMBOMROUTING BR WHERE MO.ROUTING_ID = BR.ROUTING_ID AND MO.BOM_ID = BR.BOM_ID AND MO.ITEM_ID = BR.PRODUCED_ITEM_ID) AND ITEM_ID='000000102001001608';--00120119164500359631_2023 50359247_2023 SELECT * FROM IN_ITEMBOMROUTING WHERE PRODUCED_ITEM_ID='000000102001001608' AND BOM_ID='00120119164500359631_2023' AND ROUTING_ID='50359247_2023' ;