Announcement

Collapse
No announcement yet.

Distinct in ORM select expression

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Distinct in ORM select expression

    I see we have in QueryBuilder or SelectBuilder etc.

    PHP Code:
    ->select([...])
    ->
    distinct() 
    to make the params in select distinct in the query. However, how does one accomplish the following in ORM fashion ?

    SQL/MYSQL QUERY EXAMPLE

    SELECT DISTINCT rml.id AS locationId, COUNT(DISTINCT rm.id)

  • #2
    Better to use SELECT COUNT(alias.id) FROM (SELECT DISTINCT id FROM `my_table` ... ) AS `alias`

    Like so https://github.com/espocrm/espocrm/b...apper.php#L251

    Or use the mapper's count method.

    Comment

    Working...
    X