Query remaining field names from a database table There's a database table. I know only one field name on the database table: username. How do I view  remaining field names on the table?
namespace Drupal\fixx_helper\Controller;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

class AutocompleteController extends ControllerBase
{
   public function handleAutocomplete(Request $request)
   {
      $results = [];

      $input = $request-&gt;query-&gt;get('q');
      $database = \Drupal::database();
      $my_query = $database-&gt;query(&quot;select distinct username from banner_exports.ws_students where username like '$input%'&quot;);


      while($result = $my_query-&gt;fetchAssoc()){
         $matches[] = array('value' =&gt; $result['username'], 'label' =&gt; $result['username']);
       }
       return new JsonResponse($matches);

}}
There are multiple table locations for Drupal field data: the base User entity
table users_field_data &amp; the user__$FIELD tables that contain the custom fields defined by site builder / developer. If you need field data from a DB query, then you're going to need to build a query with a few joins to put it all together.
If you're only looking for the field names then it's much earlier to use the entity field manager to pull the base &amp; custom fields:
\Drupal::service('entity_field.manager')-&gt;getFieldDefinitions('user', 'user')