Hey Nancy,<br><br>I think Randy is right, I just ran a quick test with and without <a href="http://api.drupal.org/api/function/db_rewrite_sql/6">db_rewrite_sql</a>--it works without db_rewrite_sql. This makes sense as db_rewrite_sql is among other things a regex looking for SQL keywords ('from', 'where', etc) and looks pretty much incompatible w/ subqueries.<br>
<br>Sorry I don't have any ideas for a fix.<br><br>Cheers,<br>Tim<br><br><br><br><br><div class="gmail_quote">On Thu, Apr 8, 2010 at 1:39 PM, Randy Fay <span dir="ltr"><<a href="mailto:randy@randyfay.com">randy@randyfay.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">There may certainly be something going on with db_rewrite_sql(), so you'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<div><div></div><div class="h5"><br>
<br><div class="gmail_quote">On Thu, Apr 8, 2010 at 11:20 AM, Aaron Winborn <span dir="ltr"><<a href="mailto:winborn@advomatic.com" target="_blank">winborn@advomatic.com</a>></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><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 >= 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 > 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's a problem at " AS
comments_today, cs.comment_count FROM...".<br>
</div>
<p><font size="4" color="#ff007f" 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></div></div><font color="#888888">-- <br>Randy Fay<br>Drupal Development, troubleshooting, and debugging<br><a href="mailto:randy@randyfay.com" target="_blank">randy@randyfay.com</a><br>
+1 970.462.7450<br><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Tim Loudon<br>VP of Technology, Abroad101<br>(781) 686-6096<br><a href="http://www.abroad101.com">www.abroad101.com</a><br>