Palette - Make it Colorful🎨
Palette - Visual Page Builder, no design degree required.
Scroll
12/04/2025, by Ivan
Menu
- Understanding Drupal
- Drupal System Requirements
- Installing Drupal 8
- Drupal 8 Update
- Drupal Site Administration
- Drupal 8 Modules
- Drupal Modules Comparison
- Drupal Themes
- Drupal field types
- Configuration Management
- Multisite Drupal
- Accessibility Features
- Troubleshooting in Drupal
- Creating modules for Drupal
-
Drupal 8 API
- Authenticatie-API
- Block API
- Cache API
- CKEditor API
- Configuration Management API
- Database API
- Entity API
- Theming in Drupal
- Upgrade to Drupal 11
Some SQL queries may return duplicate results. In such cases, duplicate rows can be filtered using the “DISTINCT” keyword in a static query. In a dynamic query, use the Different() method.
// Force filtering of duplicate records in the result set.
$connection = \Drupal::database();
$query = $connection->select('my_table', 'mt');
$query->fields('mt', ['my_fields']);
$query->distinct()->execute()->fetchAll();
Note that DISTINCT can lead to reduced performance, so do not use it unless there is no other way to limit the result set to avoid duplication.