diff --git a/system/Database/MySQLi/Builder.php b/system/Database/MySQLi/Builder.php index 6bfe554d732b..273e5bf3851b 100644 --- a/system/Database/MySQLi/Builder.php +++ b/system/Database/MySQLi/Builder.php @@ -53,4 +53,23 @@ class Builder extends BaseBuilder */ protected $escapeChar = '`'; + /** + * FROM tables + * + * Groups tables in FROM clauses if needed, so there is no confusion + * about operator precedence. + * + * Note: This is only used (and overridden) by MySQL. + * + * @return string + */ + protected function _fromTables(): string + { + if ( ! empty($this->QBJoin) && count($this->QBFrom) > 1) + { + return '('.implode(', ', $this->QBFrom).')'; + } + + return implode(', ', $this->QBFrom); + } }