$sql = "SELECT *,
CASE
WHEN Staffvacation.T_date=curdate() and Staffvacation.Branchcode = Cust.Branchname THEN Staffvacation.Staff1
ELSE Cust.Salecode
END AS Staff
FROM Cust LEFT JOIN Staffvacation
on Staffvacation.Branchcode = Cust.Branchname
where CustID = '{$_POST["vardata"]}' and Close_status ='A' and Staff='$UT'";
select a.* from (
SELECT Cust.*,
CASE
WHEN Staffvacation.T_date=curdate() and Staffvacation.Branchcode = Cust.Branchname THEN Staffvacation.Staff1
ELSE Cust.Salecode
END AS Staff
FROM Cust LEFT JOIN Staffvacation
on Staffvacation.Branchcode = Cust.Branchname
) as a
where a.Staff='$UT' and a.CustID = '{$_POST["vardata"]}'