Skip to content

Commit

Permalink
feat(delete): delete from another table (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
sixdouglas authored Oct 16, 2023
1 parent c80d060 commit d6ac9f4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ebook/en/content/010-delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,17 @@ The output should indicate (where x is the number of tuples in the table):
Query OK, x row(s) affected (0.047 sec)
```

Similar to the Linux `rm` command, when you use the `DELETE` statement, the data would be gone permanently, and the only way to recover your data would be by restoring a backup.
Similar to the Linux `rm` command, when you use the `DELETE` statement, the data would be gone permanently, and the only way to recover your data would be by restoring a backup.

## Delete from another table

As we saw in the two precedents sections you can `INSERT` or `UPDPATE` tables rows based on other table data. You can do the same for the `DELETE`.

For example, if you want to delete the records from the `users` table if the corresponding prospect has been disabled, you could do it this way:

```sql
delete users
from users, prospect_users
where users.username = prospect_users.username
and NOT prospect_users.active
```

0 comments on commit d6ac9f4

Please sign in to comment.