Details
- 
    Type:Bug 
- 
    Status: Done/Fixed
- 
    Priority:Minor 
- 
    Resolution: Fixed/Completed
- 
    Affects Version/s: 2.1
- 
    Fix Version/s: 2.1
- 
    Component/s: Core CiviCRM
- 
    Labels:None
Description
Ran query (see screen shot) got this error (on the sandbox too)
Error Details:
DB Error: syntax error
Database Error Code: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') IS NOT NULL AND contact_a.contact_type IN ('Individual') ) ) AND ( 1 ) GR' at line 3, 1064
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )
    [code] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] => SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name  FROM civicrm_contact contact_a 
LEFT JOIN civicrm_email `Home-email-1` ON contact_a.id = `Home-email-1`.contact_id AND `Home-email-1`.location_type_id = 1  
LEFT JOIN civicrm_location_type `Home-location_type` ON (  ( `Home-email-1`.location_type_id = `Home-location_type`.id ) )  WHERE  (  ( LOWER(`Home-email-1`.) IS NOT NULL AND contact_a.contact_type IN ('Individual') )  )  AND  ( 1 )   GROUP BY contact_a.id   [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') IS NOT NULL AND contact_a.contact_type IN ('Individual') )  )  AND  ( 1 )   GR' at line 3]
    [type] => DB_Error
    [user_info] => SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name  FROM civicrm_contact contact_a 
LEFT JOIN civicrm_email `Home-email-1` ON contact_a.id = `Home-email-1`.contact_id AND `Home-email-1`.location_type_id = 1  
LEFT JOIN civicrm_location_type `Home-location_type` ON (  ( `Home-email-1`.location_type_id = `Home-location_type`.id ) )  WHERE  (  ( LOWER(`Home-email-1`.) IS NOT NULL AND contact_a.contact_type IN ('Individual') )  )  AND  ( 1 )   GROUP BY contact_a.id   [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') IS NOT NULL AND contact_a.contact_type IN ('Individual') )  )  AND  ( 1 )   GR' at line 3]
    [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name  FROM civicrm_contact contact_a 
LEFT JOIN civicrm_email `Home-email-1` ON contact_a.id = `Home-email-1`.contact_id AND `Home-email-1`.location_type_id = 1  
LEFT JOIN civicrm_location_type `Home-location_type` ON (  ( `Home-email-1`.location_type_id = `Home-location_type`.id ) )  WHERE  (  ( LOWER(`Home-email-1`.) IS NOT NULL AND contact_a.contact_type IN ('Individual') )  )  AND  ( 1 )   GROUP BY contact_a.id   [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') IS NOT NULL AND contact_a.contact_type IN ('Individual') )  )  AND  ( 1 )   GR' at line 3]"]
)