Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I Have the below tables that i want to update the Agent table with column AgentExpirationDate with field from the other 2 tables
based on state matching the expiration date and get max expirationdate from Authority table if Authority table value is null then Account Expiration date should update instead of null.

Below are the tables
tbAccount
AccountID, AccountState, AccountExpirationdate 
AC1	       PC		   ‘2030/1212’
AC1	       MC		    ‘2022/1212’
AC2         PQ   		‘2024/1212’    
AC3	       LQ		    ‘2026/1212’
AC4         KC		    ‘2027/1212’
AC5	       PC		    ‘2028/1212’
AC6	       LC		    ‘2029/1212’
AC6         AC		    ‘2024/1212’

tblAgent
AgentID,  AgentExpirationDate 
Ag1          ‘2025-12-12’
Ag4	         ‘2027/1212’
Ag5          ‘2029-12-12’
Ag6          ‘2025-12-12’

tblAuthorities
AuthorityId,  EnityID, State, AuthorityExpirationDate ,AgentID
Au1           Ac1      PC	 ‘2023-12-12’              Ag1
Au2	          Ac1	   DC	‘2024-12-12’               Ag1 
Au3	          Ac1	   MC	‘2025-12-12’               Ag1
Au4	          Ac4      KC	NULL                       Ag4 
Au5	          Ac5	   PC	‘2023-12-12’               Ag5
Au6	          Ac5	   MV	‘2029-12-12’               Ag5      
Au7	          Ac6	   LC	‘2023-12-12’	           Ag6
Au8	          Ac6	   AC	‘2025-12-12’               Ag6


What I have tried:

Could you please assist on the join table using the above table that i am getting proper query and update values to my agent table
Posted
Updated 10-Aug-23 9:35am
v2
Comments
Richard MacCutchan 11-Aug-23 3:41am    
If that really is the format of the dates in your database then you are in for a host of problems.
Member 15090354 11-Aug-23 4:00am    
The dates are sample data but in database utc format only
CHill60 11-Aug-23 6:57am    
Can you show a worked example of your expected results and share the code you have tried so far
[no name] 13-Aug-23 11:37am    
Sounds more like a case for an "agent status query" ... And not an "update".
CHill60 5-Sep-23 4:47am    
If you are still having problems with this then please give a worked example of your expected results and share the code you have tried so far

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900