CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • DB Error LEFT JOIN civicrm_location_type `Home-location_type` ON ( )
Pages: [1]

Author Topic: DB Error LEFT JOIN civicrm_location_type `Home-location_type` ON ( )  (Read 1170 times)

SnowB1

  • Guest
DB Error LEFT JOIN civicrm_location_type `Home-location_type` ON ( )
February 12, 2009, 01:04:19 pm
I am using Civicrm 2.2 with Drupal 6. I am getting the 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 ') WHERE ( contact_a.id = 2 ) AND ( 1 ) GROUP BY contact_a.id' at line 6, 1064 When any user logs in. Of course the contact id is matched to the users id. Here is the Error Details:
Code: [Select]
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -2
    [message] => DB Error: syntax error
    [mode] => 16
    [debug_info] => SELECT DISTINCT(contact_a.id) as contact_id, contact_a.first_name  as `first_name`, contact_a.last_name  as `last_name`, IF ( contact_a.contact_type = 'Individual', contact_a.organization_name, NULL ) AS current_employer, contact_a.job_title  as `job_title`, contact_a.birth_date  as `birth_date`, `1-location_type`.id as `1-location_type_id`, `1-location_type`.name as `1-location_type`, `1-address`.id as `1-address_id`, `1-address`.city as `1-city`, `1-state_province`.id as `1-state_province_id`, `1-state_province`.abbreviation as `1-state_province`, `1-address`.postal_code as `1-postal_code`, `1-email`.id as `1-email_id`, `1-email`.email as `1-email`, `Home-location_type`.id as `Home-location_type_id`, `Home-location_type`.name as `Home-location_type`, `Home-contact`.id as `Home-contact_id`, `Home-contact`.birth_date as `Home-birth_date`  FROM civicrm_contact contact_a
LEFT JOIN civicrm_address `1-address` ON (`1-address`.contact_id = contact_a.id AND `1-address`.is_primary = 1) 
LEFT JOIN civicrm_state_province `1-state_province` ON `1-state_province`.id = `1-address`.state_province_id 
LEFT JOIN civicrm_email `1-email` ON contact_a.id = `1-email`.contact_id AND `1-email`.is_primary = 1 
LEFT JOIN civicrm_location_type `1-location_type` ON (  ( `1-address`.location_type_id = `1-location_type`.id ) OR ( `1-email`.location_type_id = `1-location_type`.id ) ) 
LEFT JOIN civicrm_location_type `Home-location_type` ON (  )  WHERE  ( contact_a.id = 2 )  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 ')  WHERE  ( contact_a.id = 2 )  AND  ( 1 )   GROUP BY contact_a.id' at line 6]
    [type] => DB_Error
    [user_info] => SELECT DISTINCT(contact_a.id) as contact_id, contact_a.first_name  as `first_name`, contact_a.last_name  as `last_name`, IF ( contact_a.contact_type = 'Individual', contact_a.organization_name, NULL ) AS current_employer, contact_a.job_title  as `job_title`, contact_a.birth_date  as `birth_date`, `1-location_type`.id as `1-location_type_id`, `1-location_type`.name as `1-location_type`, `1-address`.id as `1-address_id`, `1-address`.city as `1-city`, `1-state_province`.id as `1-state_province_id`, `1-state_province`.abbreviation as `1-state_province`, `1-address`.postal_code as `1-postal_code`, `1-email`.id as `1-email_id`, `1-email`.email as `1-email`, `Home-location_type`.id as `Home-location_type_id`, `Home-location_type`.name as `Home-location_type`, `Home-contact`.id as `Home-contact_id`, `Home-contact`.birth_date as `Home-birth_date`  FROM civicrm_contact contact_a
LEFT JOIN civicrm_address `1-address` ON (`1-address`.contact_id = contact_a.id AND `1-address`.is_primary = 1) 
LEFT JOIN civicrm_state_province `1-state_province` ON `1-state_province`.id = `1-address`.state_province_id 
LEFT JOIN civicrm_email `1-email` ON contact_a.id = `1-email`.contact_id AND `1-email`.is_primary = 1 
LEFT JOIN civicrm_location_type `1-location_type` ON (  ( `1-address`.location_type_id = `1-location_type`.id ) OR ( `1-email`.location_type_id = `1-location_type`.id ) ) 
LEFT JOIN civicrm_location_type `Home-location_type` ON (  )  WHERE  ( contact_a.id = 2 )  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 ')  WHERE  ( contact_a.id = 2 )  AND  ( 1 )   GROUP BY contact_a.id' at line 6]
    [to_string] => [db_error: message="DB Error: syntax error" code=-2 mode=callback callback=CRM_Core_Error::handle prefix="" info="SELECT DISTINCT(contact_a.id) as contact_id, contact_a.first_name  as `first_name`, contact_a.last_name  as `last_name`, IF ( contact_a.contact_type = 'Individual', contact_a.organization_name, NULL ) AS current_employer, contact_a.job_title  as `job_title`, contact_a.birth_date  as `birth_date`, `1-location_type`.id as `1-location_type_id`, `1-location_type`.name as `1-location_type`, `1-address`.id as `1-address_id`, `1-address`.city as `1-city`, `1-state_province`.id as `1-state_province_id`, `1-state_province`.abbreviation as `1-state_province`, `1-address`.postal_code as `1-postal_code`, `1-email`.id as `1-email_id`, `1-email`.email as `1-email`, `Home-location_type`.id as `Home-location_type_id`, `Home-location_type`.name as `Home-location_type`, `Home-contact`.id as `Home-contact_id`, `Home-contact`.birth_date as `Home-birth_date`  FROM civicrm_contact contact_a
LEFT JOIN civicrm_address `1-address` ON (`1-address`.contact_id = contact_a.id AND `1-address`.is_primary = 1) 
LEFT JOIN civicrm_state_province `1-state_province` ON `1-state_province`.id = `1-address`.state_province_id 
LEFT JOIN civicrm_email `1-email` ON contact_a.id = `1-email`.contact_id AND `1-email`.is_primary = 1 
LEFT JOIN civicrm_location_type `1-location_type` ON (  ( `1-address`.location_type_id = `1-location_type`.id ) OR ( `1-email`.location_type_id = `1-location_type`.id ) ) 
LEFT JOIN civicrm_location_type `Home-location_type` ON (  )  WHERE  ( contact_a.id = 2 )  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 ')  WHERE  ( contact_a.id = 2 )  AND  ( 1 )   GROUP BY contact_a.id' at line 6]"]
)

I have looked through the backend as well as the database and I am unable to find what would be causing the issue.  The only thing that worked was changing the contact_type from Individual to anything else.  Any help would be much appreciated. Thanks in advance.[/code]
« Last Edit: February 12, 2009, 01:08:13 pm by SnowB1 »

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: DB Error LEFT JOIN civicrm_location_type `Home-location_type` ON ( )
February 12, 2009, 09:13:54 pm
hi

Quote
LEFT JOIN civicrm_location_type `Home-location_type` ON (  )  WHERE  ( contact_a.id = 2 )  AND  ( 1 )   GROUP BY contact_a.id
from query it looks like root cause is missing condition for left join.

It would be good If you try to replicate here : http://sandbox.civicrm.org/
and provide detail steps to replicate issue.

thanks
kiran
You Are Designed To Choose... Defined By Choice.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: DB Error LEFT JOIN civicrm_location_type `Home-location_type` ON ( )
February 13, 2009, 11:39:09 am
The error might be triggered by changes made in the Location Types options. If you're trying to replicate on the sandbox, and have changed the default location types - make the same changes on the sandbox.

If that doesn't get us closer, then it would help to briefly enable Backtraces under Administer CiviCRM >> Debugging - and post the backtrace here so we can see where in the code the error is triggered.
Protect your investment in CiviCRM by  becoming a Member!

SnowB1

  • Guest
Re: DB Error LEFT JOIN civicrm_location_type `Home-location_type` ON ( )
February 16, 2009, 08:01:20 am
Thanks for everyones input. I took a look for custom location types but we did not have any so I looked into the fields assoctiated with them. I found some new added fields and removed them and it took care of the error. The fields were associated with a "copy of" profile and I believe for some reason this caused the error. I did not need the copy of profile so I deleted it and everything seems to be ok now :D. Thanks again for the help.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • DB Error LEFT JOIN civicrm_location_type `Home-location_type` ON ( )

This forum was archived on 2017-11-26.