There may certainly be something going on with db_rewrite_sql(), so you&#39;ll probably have to find out what the actual query is when it gets sent to mysql. Stepping into db_query() is a great way to do this.<br><br>-Randy<br>
<br><div class="gmail_quote">On Thu, Apr 8, 2010 at 11:20 AM, Aaron Winborn <span dir="ltr">&lt;<a href="mailto:winborn@advomatic.com">winborn@advomatic.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



  

<div bgcolor="#ffffff" text="#000000">
Can you post your Drupal query? Hard to troubleshoot w/o the original
code.<div><div></div><div class="h5"><br>
<br>
nan wich wrote:
<blockquote type="cite">
  
  <div style="font-family: Courier New,courier,monaco,monospace,sans-serif; font-size: 12pt; color: rgb(192, 0, 0);">
  <div>I have the following query, which works fine in PhpMyAdmin, but
Drupal upchucks on it. Why?</div>
  <div> </div>
  <div><font color="#000000">SELECT nc.nid, n.title, n.created,
nc.daycount AS views_today, nc.totalcount AS total_views, <br>
  (SELECT COUNT(*) FROM comments c WHERE c.timestamp &gt;= 1270699200
AND c.nid=nc.nid) AS comments_today, <br>
  cs.comment_count <br>
  FROM node_counter nc <br>
  INNER JOIN node n ON n.nid=nc.nid <br>
  LEFT JOIN node_comment_statistics cs ON cs.nid=nc.nid <br>
  WHERE nc.daycount &gt; 0 <br>
  ORDER BY nc.daycount DESC</font></div>
  <div> </div>
  <div>Yes, in Drupal, I do put the brackets around the table names.</div>
  <div> </div>
  <div>The error message says there&#39;s a problem at &quot; AS
comments_today, cs.comment_count FROM...&quot;.<br>
 </div>
  <p><font color="#ff007f" size="4" face="bookman old style, new york, times, serif"><i><b>Nancy
E. Wichmann, PMP</b></i></font></p>
  <p><font face="arial, helvetica, sans-serif"><span style="font-size: 11pt; color: rgb(99, 36, 35);">Sometimes
the questions are complicated and the answers are simple. - Dr. Suess</span></font></p>
  </div>
</blockquote>
<br>
<br>
</div></div><pre cols="72">-- 
Aaron Winborn

Advomatic, LLC
<a href="http://advomatic.com/" target="_blank">http://advomatic.com/</a>

Drupal Multimedia available in September!
<a href="http://www.packtpub.com/create-multimedia-website-with-drupal/book" target="_blank">http://www.packtpub.com/create-multimedia-website-with-drupal/book</a>

My blog:
<a href="http://aaronwinborn.com/" target="_blank">http://aaronwinborn.com/</a></pre>
</div>

</blockquote></div><br><br clear="all"><br>-- <br>Randy Fay<br>Drupal Development, troubleshooting, and debugging<br><a href="mailto:randy@randyfay.com">randy@randyfay.com</a><br>+1  970.462.7450<br><br>