We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 73f8c21 commit 312b738Copy full SHA for 312b738
sql-queries-11/how-to-interpret-and-fix-the-MySQL-Error-1093/fix-when-using-UPDATE-statement.sql
@@ -3,11 +3,13 @@ UPDATE Program t
3
SET t.end_date = (SELECT start_date FROM Program WHERE id=t.id);
4
5
-- This statement fixes the Error 1093 in the preceding example using a derived table
6
-UPDATE Program t
7
-SET t.end_date = (
8
- SELECT subquery_program.start_date FROM (
9
- SELECT id, start_date FROM Program WHERE id=t.id
10
- ) AS subquery_program
+UPDATE Program
+SET end_date = (
+ SELECT max_start_date
+ FROM (
+ SELECT MAX(start_date) AS max_start_date
11
+ FROM Program
12
+ ) AS derived_table
13
);
14
15
-- This set of statements fixes the Error 1093 in the same example using a temporary table
0 commit comments