Delete queries

Lastly, we can also get rid of our records using the DELETE query:

$result = $database->delete('players')
->condition('name', 'Micheal P.')
->execute();

All records that match the condition will get removed. Be careful with this because, as with update queries, leaving out a condition will basically truncate your table. The query will return the number of records affected, that is, deleted.

Although you can write SELECT queries against entity and field tables to find the IDs of the entities you want to load, you should never perform INSERT, UPDATE, or DELETE queries against these tables. You run a very high risk of corrupting your data.