Using the object of core Drupal class we can perform database queries. Delete is the data deletion query used to remove data from Database based on conditions. The delete() is a function of Drupal 8 core class used for remove records. Below is syntax and example of how to use DELETE query in Drupal 8.
// Delete the record from our table. \Drupal::database()->delete('TABLE_NAME') ->condition(CONDITION) // Condition for Remove specific records. ->execute(); <u><strong>Example:</strong></u> $query = \Drupal::database()->delete('employee', 'emp'); ->condition('employee_id', 'CE 003') ->execute();
Before Delete Table be like:
After Performing delete Query table records like: