Skip to content

Commit

Permalink
feat(update): describe how to update using another table (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
sixdouglas authored Oct 16, 2023
1 parent aa0a071 commit cd31ac7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ebook/en/content/009-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,17 @@ Now, if you again run the `SELECT id, username, about FROM users` query, you wou
| 7 | tony | 404 bio not found |
+----+----------+-------------------+
```

## Updating records using another table

As we've seen in the previous section, you can insert multiple rows in your table using another table. You can use the same principle for the update command.

To do that you simply have to list all needed table in the `update` section, then you have to explain which action you want to perform on the table, and then you need to link the table together.

For example, if you want to update the `about` field in the `users` table using the content of the `about` field in the `prospect_users` table, you would do something like this:

```sql
update users, prospect_users
set users.about = prospect_users.about
where prospect_users.username = users.username;
```

0 comments on commit cd31ac7

Please sign in to comment.