<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:12pt"><DIV></DIV>
<DIV>I have other queries with subqueries that work just fine.<BR> </DIV>
<P><FONT face="bookman old style, new york, times, serif" color=#ff007f size=4><EM><STRONG>Nancy E. Wichmann, PMP</STRONG></EM></FONT></P>
<DIV><BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif"><BR>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><FONT face=Tahoma size=2>
<HR SIZE=1>
<B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> T L <tloud365@gmail.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> development <development@drupal.org><BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Thu, April 8, 2010 2:06:36 PM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [development] Strange query problem<BR></FONT><BR>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" target=_blank rel=nofollow>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" target=_blank rel=nofollow ymailto="mailto:randy@randyfay.com">randy@randyfay.com</A>></SPAN> wrote:<BR>
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">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 rel=nofollow ymailto="mailto:winborn@advomatic.com">winborn@advomatic.com</A>></SPAN> wrote:<BR>
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>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-SIZE: 12pt; COLOR: rgb(192,0,0); FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif">
<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 face="bookman old style, new york, times, serif" color=#ff007f size=4><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>--
Aaron Winborn
Advomatic, LLC
http://advomatic.com/
Drupal Multimedia available in September!
http://www.packtpub.com/create-multimedia-website-with-drupal/book
My blog:
http://aaronwinborn.com/</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 rel=nofollow ymailto="mailto:randy@randyfay.com">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/" target=_blank rel=nofollow>www.abroad101.com</A><BR></DIV></DIV></div></body></html>