Answers.Body: <p>I know this is old but it seems if there is a Smart Group that has no contacts it will throw up an error, at least, it does in my instance. I just disabled that Smart Group and the Update link doesn't throw a syntax error any more.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-06T23:48:14.160Z
Answers.LastActivityDate: 2017-01-06T23:48:14.160Z
Answers.UserDisplayName: BruceW
Body: <p>This is a bit of a corner case.  This is reproduced in <a href="http://d46.demo.civicrm.org" rel="nofollow">http://d46.demo.civicrm.org</a>.</p>
  
  <p>Go to Contacts => Manage Groups</p>
  
  <p>Click on Update Smart Group Counts (left side below the Find Groups box)</p>
  
  <p>It will error with a syntax error.  It errors on the smart group LYBUNT.</p>
  
  <p>This smart group was created with Search => Custom Searches => Contributions made in Year X and not Year Y.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-28T22:21:24.753Z
Comments.Text: If you can replicate this on the demo site, and you're getting an error, then you've found a bug.  You can report it via the issue queue (https://civicrm.org/issue-queue).  Note that it's unlikely to be fixed without submitting to the paid issue queue (https://civicrm.org/paid-issue-queue) or submitting a patch!
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-28T23:13:31.777Z
Comments.Text: Yea, I guess I really should have and I will.    This was an offshoot of another one.  Monish Deb asked me to create a new one.  Same error different cause.  He fixed the other case.  Generating dynamic sql and getting all the clauses just right is an art.
Comments.UserDisplayName: Paul-Tahoe
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-28T23:20:12.977Z
Comments.Text: Created issue CRM-16931 for this.
Comments.UserDisplayName: Paul-Tahoe
Tags: <smartgroups>
Title: Update smart group counts errors with syntax error (AND instead of WHERE in sql)
ThreadText: # Update smart group counts errors with syntax error (AND instead of WHERE in sql)
  
  (Asked by: username_0 on 2015-07-28)
  
  This is a bit of a corner case. This is reproduced in <http://d46.demo.civicrm.org>.
  
  Go to Contacts => Manage Groups
  
  Click on Update Smart Group Counts (left side below the Find Groups box)
  
  It will error with a syntax error. It errors on the smart group LYBUNT.
  
  This smart group was created with Search => Custom Searches => Contributions made in Year X and not Year Y.
  
  **Tags:** smartgroups
  
  > **Comments:**
  > **username_1**: If you can replicate this on the demo site, and you're getting an error, then you've found a bug.  You can report it via the issue queue (https://civicrm.org/issue-queue).  Note that it's unlikely to be fixed without submitting to the paid issue queue (https://civicrm.org/paid-issue-queue) or submitting a patch!  
  > **username_0**: Yea, I guess I really should have and I will.    This was an offshoot of another one.  Monish Deb asked me to create a new one.  Same error different cause.  He fixed the other case.  Generating dynamic sql and getting all the clauses just right is an art.  
  > **username_0**: Created issue CRM-16931 for this.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-01-06. Score: 2
  
  I know this is old but it seems if there is a Smart Group that has no contacts it will throw up an error, at least, it does in my instance. I just disabled that Smart Group and the Update link doesn't throw a syntax error any more.
  
  
  ---
  
  