Functions and operators
The Drupal database layer does not provide cross-database abstraction for SQL functions. To ensure portability across supported database engines, your code should use only those functions that are known to be part of the ANSI standard and supported in all databases supported by Drupal. The following is still an incomplete list. The form used here is recommended, as other syntax variants may not work across all databases.
Note that the database layer does not whitelist operators, so you can pass a non-standard function like REPLACE(), and it will work for databases that support the syntax.
Logical Operators
- AND
- OR
- NOT
Comparison Operators
- <
- >
- <=
- >=
- <>
- LIKE
String Functions and Operators
- CONCAT(string1, string2)
- SUBSTRING(string, from, length)
- SUBSTRING_INDEX(string, delimiter, count)
- LENGTH(string)
Mathematical Functions and Operators
- GREATEST(num1, num2)
- POW(num1, num2)
- LOG(base, value)
Aggregate Functions
- COUNT(expression)
- SUM(expression)
- AVG(expression)
- MIN(expression)
- MAX(expression)
Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.