query to fetch all path aliases's content type and title I want to know the titles and content types of all the aliases given in table   url_alias . For this, I'm writing query :

$connection = \Drupal::database();
    $query = $connection-&gt;select('node_field_data', 'n');
    $query-&gt;join('url_alias', 'u', '/node/n.nid = u.source');
    $result = $query-&gt;fields('n', ['changed', 'nid','type'])
                    -&gt;fields('u', ['alias'])
              //-&gt;condition('n.type',$content_type, '=')
              //-&gt;orderBy('n.title', 'ASC')
              -&gt;execute();


    foreach ($result as $rows) {
        $totalRows[] = $rows;

      }


But query is not giving the desired result. What's wrong with the query?
Can you try:

$connection = \Drupal::database();
$query = $connection-&gt;select('node_field_data', 'n');
$query-&gt;leftJoin('url_alias', 'u', 'n.nid = u.source');
$result = $query-&gt;fields('n', ['changed', 'nid', 'type']);
$result-&gt;addField('u', ['alias']);

$result-&gt;execute();


foreach ($result as $rows) {
  $totalRows[] = $rows;
}


I saw two main problems.

1) Basically you had a mistake that was causing runtime error: 

$query-&gt;join('url_alias', 'u', '/node/n.nid = u.source');


2) Using join, where for this you need left join.

Different types of joins:
https://stackoverflow.com/questions/5706437/whats-the-difference-between-inner-join-left-join-right-join-and-full-join

Tip: Before running $result->execute(), you can run $string = $result->__toString(). 
This will give you the produced raw SQL. You can use it in a tool like adminer/phpmyadmin to debug in more detail.

Best regards,
Oleg