delete from entPhysical where deleted != 'NULL'; select devices.hostname, ports.ifName, ports.port_descr_descr, ports.ifAdminStatus, ports.ifOperStatus, entPhysical.entPhysicalVendorType, entPhysical.entPhysicalDescr, entPhysical.entPhysicalSerialNum from ports Inner Join devices On devices.device_id = ports.device_id Inner Join entPhysical On entPhysical.device_id = ports.device_id And ( entPhysical.entPhysicalName = ports.ifName Or entPhysical.entPhysicalName = ports.port_label Or entPhysical.entPhysicalName = CONCAT(ports.ifname, '(volt)') ) where entPhysicalSerialNum != '';