I have a query like this:
SELECT DISTINCT field_name FROM table_name
I tried:
\Drupal::database()->select('table_name', 't');
$query->fields('t', ['field_name']);
$result = $query->execute();
But since Connection::select
expects base table this did not work.
How am I supposed to execute it? I used entityQuery previously. I could not find a way to filter out the unique values of only one field using entityQuery.
Note: I went through this example which is basically using Connection::select
. But Connection::select
requires to provide the base table. In entityQuery (https://api.drupal.org/api/drupal/core!lib!Drupal.php/function/Drupal%3A%3AentityQuery/8.2.x) I did not have to provide the base table data.