Doozer1979
Registered User.
- Local time
- Today, 09:09
- Joined
- Jul 4, 2007
- Messages
- 32
Hello,
I have multiple update queries that i would like to combine into one statement for performance reasons. I know you can update multiple columns in an update query, but the problem is all the statements have different WHERE clauses. I'm assuming this would be solved by using subqueries, but i'm not sure of the syntax. Would this actaully have performance benefits combining all the queries into one?
UPDATE Recorded_Crime_Committed_Formatted SET Previous7 = True
WHERE Cri_Committed_Date Between Forms!frmMain!prev7Start And Forms!frmMain!prev7End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Current7 = True
WHERE Cri_Committed_Date BETWEEN Forms!frmMain!cur7Start And Forms!frmMain!cur7End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Current14 = True
WHERE Cri_Committed_Date BETWEEN Forms!frmMain!cur14Start And Forms!frmMain!cur14End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Previous14 = True
WHERE Cri_Committed_Date Between Forms!frmMain!prev14Start And Forms!frmMain!prev14End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Current28 = True
WHERE Cri_Committed_Date BETWEEN Forms!frmMain!cur28Start And Forms!frmMain!cur28End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Previous28 = True
WHERE Cri_Committed_Date Between Forms!frmMain!prev28Start And Forms!frmMain!prev28End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Current56 = True
WHERE Cri_Committed_Date BETWEEN Forms!frmMain!cur56Start And Forms!frmMain!cur56End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Previous56 = True
WHERE Cri_Committed_Date Between Forms!frmMain!prev56Start And Forms!frmMain!prev56End+1;
I have multiple update queries that i would like to combine into one statement for performance reasons. I know you can update multiple columns in an update query, but the problem is all the statements have different WHERE clauses. I'm assuming this would be solved by using subqueries, but i'm not sure of the syntax. Would this actaully have performance benefits combining all the queries into one?
UPDATE Recorded_Crime_Committed_Formatted SET Previous7 = True
WHERE Cri_Committed_Date Between Forms!frmMain!prev7Start And Forms!frmMain!prev7End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Current7 = True
WHERE Cri_Committed_Date BETWEEN Forms!frmMain!cur7Start And Forms!frmMain!cur7End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Current14 = True
WHERE Cri_Committed_Date BETWEEN Forms!frmMain!cur14Start And Forms!frmMain!cur14End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Previous14 = True
WHERE Cri_Committed_Date Between Forms!frmMain!prev14Start And Forms!frmMain!prev14End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Current28 = True
WHERE Cri_Committed_Date BETWEEN Forms!frmMain!cur28Start And Forms!frmMain!cur28End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Previous28 = True
WHERE Cri_Committed_Date Between Forms!frmMain!prev28Start And Forms!frmMain!prev28End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Current56 = True
WHERE Cri_Committed_Date BETWEEN Forms!frmMain!cur56Start And Forms!frmMain!cur56End+1;
UPDATE Recorded_Crime_Committed_Formatted SET Previous56 = True
WHERE Cri_Committed_Date Between Forms!frmMain!prev56Start And Forms!frmMain!prev56End+1;