I have the following tables:
Employee
ID Name Job_Status
6789-1 Joe N
6789-2 Joe N
6789-3 Joe N
EmployeeQualification
ID Name Qualifications Acquired_Date
6789-1 Joe PA NULL
6789-1 Joe Secetary NULL
6789-1 Joe SalesMan 2009-10-10
What I have to do is write and update Statement which will update The Job_Status for all the above to Y when there is no NULL value in Acquired_Date column...
So only after Acquired_Date IS NOT NULL update Job_Status = 'Y. Therefore,
EmployeeQualification
ID Name Qualifications Acquired_Date
6789-1 Joe PA 2009-11-6
6789-1 Joe Secetary 2009-06-11
6789-1 Joe SalesMan 2009-10-10
then update the Job_Status for as following:
Employee
ID Name Job_Status
6789-1 Joe Y
6789-2 Joe Y
6789-3 Joe Y
My query is not working:
Any help is much appreciated...
Thanks...
Employee
ID Name Job_Status
6789-1 Joe N
6789-2 Joe N
6789-3 Joe N
EmployeeQualification
ID Name Qualifications Acquired_Date
6789-1 Joe PA NULL
6789-1 Joe Secetary NULL
6789-1 Joe SalesMan 2009-10-10
What I have to do is write and update Statement which will update The Job_Status for all the above to Y when there is no NULL value in Acquired_Date column...
So only after Acquired_Date IS NOT NULL update Job_Status = 'Y. Therefore,
EmployeeQualification
ID Name Qualifications Acquired_Date
6789-1 Joe PA 2009-11-6
6789-1 Joe Secetary 2009-06-11
6789-1 Joe SalesMan 2009-10-10
then update the Job_Status for as following:
Employee
ID Name Job_Status
6789-1 Joe Y
6789-2 Joe Y
6789-3 Joe Y
My query is not working:
Code:
Update Employee
SET [Job_Status] = 'Y'
Where [ID] Like Left('ID', PatIndex('%-%', 'ID' + '-')-1) + '%'
and exists (select 1
from EmployeeQualification EQ
where EQ.Acquired_Date IS NOT NULL
and EQ.ID = ID)
Any help is much appreciated...
Thanks...