Neues in der Kategorie civicrm

Fun mit civicrm

| 1 Kommentar | Keine TrackBacks
Heute schlug eine nette Query aus civicrm in #mysql.de auf

 SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name  
FROM civicrm_contact contact_a
LEFT JOIN civicrm_group_contact `civicrm_group_contact-101`
ON contact_a.id = `civicrm_group_contact-101`.contact_id
LEFT JOIN civicrm_group_contact `civicrm_group_contact-102`
ON contact_a.id = `civicrm_group_contact-102`.contact_id
LEFT JOIN civicrm_group_contact `civicrm_group_contact-46`
ON contact_a.id = `civicrm_group_contact-46`.contact_id
LEFT JOIN civicrm_group_contact `civicrm_group_contact-60`
ON contact_a.id = `civicrm_group_contact-60`.contact_id
LEFT JOIN civicrm_group_contact `civicrm_group_contact-6`
ON contact_a.id = `civicrm_group_contact-6`.contact_id
LEFT JOIN civicrm_group_contact `civicrm_group_contact-94`
ON contact_a.id = `civicrm_group_contact-94`.contact_id
LEFT JOIN civicrm_group_contact `civicrm_group_contact-95`
ON contact_a.id = `civicrm_group_contact-95`.contact_id
LEFT JOIN civicrm_group_contact `civicrm_group_contact-97`
ON contact_a.id = `civicrm_group_contact-97`.contact_id
LEFT JOIN civicrm_group_contact `civicrm_group_contact-99`
ON contact_a.id = `civicrm_group_contact-99`.contact_id
LEFT JOIN civicrm_group_contact_cache `civicrm_group_contact_cache_6`
ON contact_a.id = `civicrm_group_contact_cache_6`.contact_id
WHERE
(
(
( `civicrm_group_contact-6`.group_id IN ( 6 )
AND
`civicrm_group_contact-6`.status IN ("Added" )
)
OR
( `civicrm_group_contact_cache_6`.group_id = 6
)
)
)
AND
(
( `civicrm_group_contact-6`.group_id IN ( 6 )
AND `civicrm_group_contact-6`.status IN ("Added")
)
OR
( `civicrm_group_contact-46`.group_id IN ( 46 )
AND `civicrm_group_contact-46`.status IN ("Added")
)
OR
( `civicrm_group_contact-60`.group_id IN ( 60 )
AND `civicrm_group_contact-60`.status IN ("Added")
) OR ( `civicrm_group_contact-94`.group_id IN ( 94 )
AND `civicrm_group_contact-94`.status IN ("Added") )
OR ( `civicrm_group_contact-95`.group_id IN ( 95 )
AND `civicrm_group_contact-95`.status IN ("Added") )
OR ( `civicrm_group_contact-97`.group_id IN ( 97 )
AND `civicrm_group_contact-97`.status IN ("Added") )
OR ( `civicrm_group_contact-99`.group_id IN ( 99 )
AND `civicrm_group_contact-99`.status IN ("Added") )
OR ( `civicrm_group_contact-101`.group_id IN ( 101 )
AND `civicrm_group_contact-101`.status IN ("Added") )
OR ( `civicrm_group_contact-102`.group_id IN ( 102 )
AND `civicrm_group_contact-102`.status IN ("Added") ) );

Was sich die Entwickler dabei dachten ist mir nicht klar, denn es ist nichts anderes als

SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name
FROM civicrm_contact contact_a;

Sprich die Menge aller Großbuchstaben des ersten Buchstaben von sort_name.

*kopfkratz*

Danke an Rince der mit der Query in #mysql.de aufschlug.
Wer Lust hat ist gerne eingeladen auch im irc aufzuschlagen:)