select distinct concat(user_info.first_name, ' ', user_info.last_name) as assigned_to_user_str, suppliers.company_name as assigned_to_supplier_str, tag.mnemonic as mnemonic, tag_categories.name as category_str, locations.name as location_str, workorder.* from tag_categories, locations, tag, workorder left join user_info on workorder.assigned_to_user = user_info.id left join suppliers on workorder.assigned_to_supplier = suppliers.supplier_id where workorder.category = tag_categories.id and workorder.location = locations.id and tag.tag_id = workorder.tag_id workorder.tag_id = #tagId# workorder.date_completed $dateCompletedOperator$ date_completed = #dateCompleted# workorder.prev_maint $prevMaintOperator$ workorder.location = #location# workorder.category = #category# assigned_to_user = #assignedToUser# assigned_to_supplier = #assignedToSupplier# order by #orderBy# desc