diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index f377303c..7c249dae 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -4118,21 +4118,13 @@ export class ProfileController extends Controller { queryLike = "profile.position LIKE :keyword"; } else if (searchField == "posNo") { queryLike = ` - IF(current_holders.orgChild4Id IS NOT NULL, - CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo), '' - ) LIKE :keyword OR - IF(current_holders.orgChild3Id IS NOT NULL, - CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo), '' - ) LIKE :keyword OR - IF(current_holders.orgChild2Id IS NOT NULL, - CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo), '' - ) LIKE :keyword OR - IF(current_holders.orgChild1Id IS NOT NULL, - CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo), '' - ) LIKE :keyword OR - IF(current_holders.orgChild1Id IS NULL, - CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo), '' - ) LIKE :keyword + CASE + WHEN current_holders.orgChild4Id IS NOT NULL THEN CONCAT(orgChild4.orgChild4ShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild3Id IS NOT NULL THEN CONCAT(orgChild3.orgChild3ShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild2Id IS NOT NULL THEN CONCAT(orgChild2.orgChild2ShortName, current_holders.posMasterNo) + WHEN current_holders.orgChild1Id IS NOT NULL THEN CONCAT(orgChild1.orgChild1ShortName, current_holders.posMasterNo) + ELSE CONCAT(orgRoot.orgRootShortName, current_holders.posMasterNo) + END LIKE :keyword `; } let nodeCondition = "1=1";