I am building a SQL query one step at a time in different parts of my
application. I am using MySQL 4.1

Currently, the query being automatically built is:

 (SELECT doc_index.doc_id, doc_index.doc_type, doc_index.ref_id,
doc_index.create_date, doc_index.modified_date FROM doc_index) JOIN
snack ON doc_index.ref_id = snack.snack_id AND doc_index.doc_type = %s
JOIN drink ON doc_index.ref_id = drink.drink_id AND doc_index.doc_type
= %s


First, MySQL throws a syntax error because of the parenthesis around
the SELECT expression. Is there any way to turn that off?

Second, this has to be a LEFT JOIN, not a standard join, so something
like this:

SELECT doc_index.doc_id, doc_index.doc_type, doc_index.ref_id,
doc_index.create_date, doc_index.modified_date
FROM doc_index
LEFT JOIN snack ON doc_index.ref_id = snack.snack_id AND
doc_index.doc_type = %s
LEFT JOIN drink ON doc_index.ref_id = drink.drink_id AND
doc_index.doc_type = %s


Here is a condensed version of the code

stmt = doc_type_table.select()

join_table = get_join_table('widgets')
stmt = stmt.join(join_table,
SA.and_(doc_type_table.c.ref_id==join_table.primary_key[0],
        doc_type_table.c.doc_type=='widgets'))

join_table2 = get_join_table('spam')
stmt = stmt.join(join_table2,
SA.and_(doc_type_table.c.ref_id==join_table2.primary_key[0],
        doc_type_table.c.doc_type=='spam'))

stmt.execute()

I tried hacking with the _group_parenthesized attribute, but to no
avail on the parenthesis.

Any help would be appreciated.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to