[TYPO3-core] FYI #16455: DISTINCT as a function is not compatible with DBAL

Jigal van Hemert jigal at xs4all.nl
Thu Nov 18 08:17:50 CET 2010


Hi,

On 17-11-2010 23:12, Xavier Perseguers wrote:
> Problem:
> EM tool is using DISTINCT keyword as a function:
>
> SELECT COUNT(DISTINCT(column)) ...
>
> instead of the DBAL compatible way:
>
> SELECT COUNT(DISTINCT column)

I've searched the MySQL documentation, but I can't find any reference to 
using DISTINCT as a function. I haven't found any difference between 
using DISTINCT and DISTINCT(), so I'm getting more and more convinced 
that MySQL interpretes the "function" as the keyword DISTINCT plus an 
expression which is surrounded by parentheses (which is allowed):

SELECT COUNT(DISTINCT (column) ) ...

or you could write:

SELECT COUNT(DISTINCT ((((column)))) ) ...

It has the same result as:

SELECT COUNT(DISTINCT`column`) ...

Maybe you can tell more about how other DBMSs deal with spaces between 
keywords and expressions? Is this documented in the 
DBAL-compatible-query-rules?

-- 
Kind regards / met vriendelijke groet,

Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh


More information about the TYPO3-team-core mailing list