Search code examples
sqlmariadbsyntax-error

Use of GROUP_CONCAT() results in error 1064


I have a very simple table:

CREATE TABLE `invoice_physician` (
  `INVOICENR` varchar(12) NOT NULL,
  `PHYSICIAN` varchar(255) NOT NULL DEFAULT '',
  `modified` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`INVOICENR`,`PHYSICIAN`)
);

And I want to aggregate with GROUP_CONCAT():

This works fine:

select
    date_format (max(modified), '%d.%m.%Y') `Entered`,
    group_concat(PHYSICIAN separator ' / ') Doktor
from
    invoice_physician
group by
    INVOICENR;

but this results in an #1064 error @ line 3

select
    date_format (max(modified), '%d.%m.%Y') `Entered`,
    group_concat (PHYSICIAN separator ' / ') Doktor
from
    invoice_physician
group by
    INVOICENR;

I use a SQL beautifier that helpfully adds spaces after function names, but in this case, apparently the MariaDB does not like that. Is this a bug in MariaDB parser?

software version
OS: Windows 10
DB: MariaDB 11.4.2

Solution

  • From the mariadb documentation

    For builtin functions and user-defined functions, spaces are not allowed between the function name and the open parenthesis, unless the IGNORE_SPACE SQL_MODE is set