The core "Migrate Drupal" module in Drupal 8 provides API support for migrating from Drupal to Drupal, and the "Migrate Drupal UI" module offers a simple user interface for upgrading from older versions of Drupal.
Dynamic queries refer to queries that are dynamically created by Drupal, rather than being supplied as an explicit query string. All insert, update, delete, and merge queries must be dynamic. Select queries can be either static or dynamic. Hence, "dynamic query" usually refers to a dynamic Select query.
The Select query builder supports using expressions in the field list. Example expressions include "double the age field," "count of all name fields," and a substring of the title field. Note that many expressions may use SQL functions, and not all SQL functions are standardized across all databases. Module developers must ensure that only expressions compatible with supported databases are used. (See List of functions and operators)
Any query can have a corresponding "count query". A count query returns the number of rows in the original query. To get a count query from an existing query (which is a select query object implementing the SelectInterface), use the countQuery() method.
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.
To group by a given field, use the groupBy() method.
$query->groupBy('uid');
The code above instructs the query to group by the uid field. Note that the field name here must be the alias created by the addField() or addExpression() methods, so in most cases you will want to use the return value from those methods to ensure the correct alias is used.
To get the count of rows grouped by a field, such as uid, you can do the following:
Merge queries are a special type of hybrid query. Although the syntax for them is defined in the SQL 2003 specification, virtually no database supports the standard syntax. However, most provide an alternative implementation using database-specific syntax. Drupal’s merge query builder abstracts the concept of a merge query into a structured object that can be compiled into the appropriate syntax for each database. They are sometimes referred to as "UPSERT" queries, a combination of UPDATE and INSERT.