Get the App
SLTechnology News&Howtos  ›  Database  › 

The method of updating one table with another through the SQL statement

Shulou Source: shulou.com Published: 2022-06-01 01:44:57 10月01日 Update

This article will explain in detail how to update another table with one table through the SQL sentence. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

The method of updating one table with another through the SQL statement: it can be done using the SELECT INTO statement. For example, [update visit set visit.nm = user.nm from user where visit.uid = user.uid].

If you want to insert data from one table into another, you can use a SELECT INTO statement or an INSERT INTO SELECT statement.

For example:

There are now the following two tables:

User information table users

History information table visit

Update sql statement

Update visitset visit.username = users.username, visit.phone = users.phonefrom userswhere visit.uid = users.uid

Update results:

History information table visit

Vid uid time username phone1 1 2019-06-15 19:23:45 Tom 13966666666662 2 2019-06-18 14:03:59 3 2019-06-23 07:45:21 Lucy 139999999999 so much for sharing the method of updating one table with another table through the SQL statement I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Sentences updates methods information history more articles good practical content data articles users knowledge results references help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft vpn macOS Xiaomi Apple