zhannngchen commented on code in PR #17639:
URL: https://github.com/apache/doris/pull/17639#discussion_r1133416203


##########
docs/zh-CN/docs/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/UPDATE.md:
##########
@@ -76,9 +102,69 @@ UPDATE test SET v1 = 1 WHERE k1=1 and k2=2;
 UPDATE test SET v1 = v1+1 WHERE k1=1;
 ```
 
-### Keywords
+<version since="dev">
 
-    UPDATE
+UPDATE_FROM
+
+</version>
 
-### Best Practice
+3. 使用`t2`和`t3`表连接的结果,更新`t1`
 
+```sql
+-- 创建t1, t2, t3三张表
+CREATE TABLE t1
+  (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE)
+UNIQUE KEY (id)
+DISTRIBUTED BY HASH (id)
+PREOPERTIES('replication_num'='1');
+
+CREATE TABLE t2
+  (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE)
+DISTRIBUTED BY HASH (id)
+PREOPERTIES('replication_num'='1');
+
+CREATE TABLE t3
+  (id INT)
+DISTRIBUTED BY HASH (id)
+properties('replication_num'='1');
+
+-- 插入数据
+INSERT INTO t1 VALUES
+  (1, 1, '1', 1.0, '2000-01-01'),
+  (2, 2, '2', 2.0, '2000-01-02'),
+  (3, 3, '3', 3.0, '2000-01-03');
+
+INSERT INTO t2 VALUES
+  (1, 10, '10', 10.0, '2000-01-10'),
+  (2, 20, '20', 20.0, '2000-01-20'),
+  (3, 30, '30', 30.0, '2000-01-30'),
+  (4, 4, '4', 4.0, '2000-01-04'),
+  (5, 5, '5', 5.0, '2000-01-05');
+
+INSERT INTO t3 VALUES
+  (1),
+  (4),
+  (5);
+
+-- 更新 t1
+UPDATE t1
+  SET t1.c1 = t2.c1, t1.c3 = t2.c3 * 100
+  FROM t2 INNER JOIN t3 ON t2.id = t3.id
+  WHERE t1.id = t2.id;
+```
+
+预期结果为,更新了`t1`表`id`为`1`的列
+
+```
++----+----+----+--------+------------+
+| id | c1 | c2 | c3     | c4         |
++----+----+----+--------+------------+
+| 3  | 3  | 3  |    3.0 | 2000-01-03 |
+| 2  | 2  | 2  |    2.0 | 2000-01-02 |
+| 1  | 10 | 1  | 1000.0 | 2000-01-01 |
++----+----+----+--------+------------+
+```
+

Review Comment:
   Should add some description on sequence column support in this doc



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to