# Delete

To delete (remove) data from a table, the `DELETE` statement is used. `DELETE`can be used in two ways:

1. To delete specific rows from a table
2. To delete all rows from a table

```php
DELETE FROM table_name
WHERE condition;
```

```php
DELETE FROM Customers
WHERE cust_id = "1000000006";
```

If the `WHERE` clause were omitted, this statement would have deleted every customer in the table!

The `DELETE` statement deletes rows from tables, even all rows from tables. But `DELETE` never deletes the table itself.

## Multi-Table Deletes

For example, to delete rows from both`T1` and`T2` tables that meet a specified condition, you use the following statement:

```php
DELETE T1, T2
FROM T1 INNER JOIN T2 ON T1.key = T2.key
WHERE condition;
```

* Notice that you put table names`T1`and`T2`between the `DELETE`and`FROM` keywords. If you omit`T1`table, the`DELETE`statement only deletes rows in `T2`table. Similarly, if you omit`T2`table, the`DELETE`statement will delete only rows in `T1`table.
* The expression`T1.key = T2.key`specifies the condition for matching rows between`T1`and`T2`tables that will be deleted.
* The condition in the  `WHERE`clause determine rows in the`T1`and`T2`that will be deleted.

In the following code, we INNER JOINs three tables.

```php
DELETE t1, t2 
FROM t1 INNER JOIN t2 INNER JOIN t3
WHERE t1.id=t2.id AND t2.id=t3.id;
```

```php
DELETE FROM t1, t2 
USING t1 INNER JOIN t2 INNER JOIN t3
WHERE t1.id=t2.id AND t2.id=t3.id;
```

These two syntax return the same results. These statements use all three tables when searching for rows to delete, but delete matching rows only from tables`t1`and`t2`.

For the first multiple-table syntax, only matching rows from the tables listed before the `FROM`clause are deleted. For the second multiple-table syntax, only matching rows from the tables listed in the `FROM`clause (before the`USING`clause) are deleted. The effect is that you can delete rows from many tables at the same time and have additional tables that are used only for searching.
