I need help fixing the update statement below.
The update statement updates all of the records on the table for a specific day. This is not what I want to happen.
I would like the cleared field updated with an ‘N’ if the concatenated fields is found in a subset of concatenated fields (ref subquery) where the edate +1
Does anyone know how the fix the update statement below
So that the only the appropriate records will be updated?
UPDATE SUSF SET CLEARED = 'N'
WHERE EDATE + 1 IN (SELECT EDATE FROM SUSF)
AND USERID_2||B_C||B_AO||B_NUM||T_C||AO||T_NUM in (SELECT USERID_2||B_C||B_AO||B_NUM||T_C||AO||T_NUM
FROM SUSF)
AND EDATE IN ('01-DEC-06' , '30-NOV-06' );
EDATE USERID_2||B_C||B_AO||B_NUM||T_C||AO||T
--------- --------------------------------------
30-NOV-06 ZTI741TO10Z15129TO10741T71587
01-DEC-06 ZTI741TO10Z15129TO10741T71587
01-DEC-06 ZTI741TO10Z20454TO10741T71672
30-NOV-06 ZTI741TO10Z20454TO10741T71672
01-DEC-06 ZTI792TP10 TP10792T7150201
30-NOV-06 ZTI792TP10 TP10792T7150201
The update statement updates all of the records on the table for a specific day. This is not what I want to happen.
I would like the cleared field updated with an ‘N’ if the concatenated fields is found in a subset of concatenated fields (ref subquery) where the edate +1
Does anyone know how the fix the update statement below
So that the only the appropriate records will be updated?
UPDATE SUSF SET CLEARED = 'N'
WHERE EDATE + 1 IN (SELECT EDATE FROM SUSF)
AND USERID_2||B_C||B_AO||B_NUM||T_C||AO||T_NUM in (SELECT USERID_2||B_C||B_AO||B_NUM||T_C||AO||T_NUM
FROM SUSF)
AND EDATE IN ('01-DEC-06' , '30-NOV-06' );
EDATE USERID_2||B_C||B_AO||B_NUM||T_C||AO||T
--------- --------------------------------------
30-NOV-06 ZTI741TO10Z15129TO10741T71587
01-DEC-06 ZTI741TO10Z15129TO10741T71587
01-DEC-06 ZTI741TO10Z20454TO10741T71672
30-NOV-06 ZTI741TO10Z20454TO10741T71672
01-DEC-06 ZTI792TP10 TP10792T7150201
30-NOV-06 ZTI792TP10 TP10792T7150201