On Apr 11, 2014, at 2:02 PM, Mauricio de Abreu Antunes 
<mauricio.abr...@gmail.com> wrote:

> 
> 
> My consideration here are:
> 
> Why is my code translation to "FROM   client_global_counter, (SELECT 
> client_glogal_counter2.date" instead of just "FROM  (SELECT 
> client_glogal_counter2.date"?

OK when you see this pattern,   "FROM x, (SELECT ... FROM .. x)", that means 
you are calling upon columns directly from "x" in some cases and from the 
subquery in others.

You need to make sure that your outermost SELECT always selects things in 
context of the subquery, and not the things that are contained within it.

This can be illustrated with some rudimentary table objects:

from sqlalchemy.sql import select, table, column

t1 = table('t1', column('x'), column('y'))
s1 = select([t1]).alias()

s2 = select([s1.c.x, s1.c.y])  # correct

s3 = select([t1.c.x, s1.c.y])  # (typically) incorrect

print s2
# prints:
# SELECT anon_1.x, anon_1.y
# FROM (SELECT t1.x AS x, t1.y AS y
# FROM t1) AS anon_1

print s3
# prints:
# SELECT t1.x, anon_1.y
# FROM t1, (SELECT t1.x AS x, t1.y AS y
# FROM t1) AS anon_1


I didn't dig into your code but hopefully you can see where this is happening.


> 
> MySQL is not recognizing some field like client_global_counter.date, hour and 
> minute in the first line. Looks like my alias is not doing the right thing or 
> I am doing something wrong.

define "not recognizing".

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to