当前位置: 动力学知识库 > 问答 > 编程问答 >

sqlalchemy generated SQL not running on Sybase

问题描述:

sqlalchemy is generating this query for me:

SELECT INSTRUMENT_GROUP.id_imnt_grp AS "INSTRUMENT_GROUP_id_imnt_grp",INSTRUMENT_GROUP.nm_imnt_grp AS "INSTRUMENT_GROUP_nm_imnt_grp", INSTRUMENT_GROUP.type_imnt_grp AS "INSTRUMENT_GROUP_type_imnt_grp",

anon_1."IMNT_GRP_MEMBERS_id_imnt_grp" AS "anon_1_IMNT_GRP_MEMBERS__1"

FROM (SELECT IMNT_GRP_MEMBERS.id_imnt_grp AS "IMNT_GRP_MEMBERS_id_imnt_grp"

FROM IMNT_GRP_MEMBERS

WHERE 452 = IMNT_GRP_MEMBERS.id_imnt) AS anon_1

JOIN INSTRUMENT_GROUP ON INSTRUMENT_GROUP.id_imnt_grp = anon_1."IMNT_GRP_MEMBERS_id_imnt_grp"

ORDER BY anon_1."IMNT_GRP_MEMBERS_id_imnt_grp"

However, it wont run via sqlalchemy, using a Sybase 15.5 driver via pyodbc. However, it runs fine via SQuirreL SQL using a jconnect driver.

Any ideas why this would be or how to fix?

网友答案:

If you are performing an INNER JOIN then try changing the JOIN part of the query like this by adding the word INNER before the JOIN.

anon_1 INNER JOIN INSTRUMENT_GROUP 
ON INSTRUMENT_GROUP.id_imnt_grp = anon_1."IMNT_GRP_MEMBERS_id_imnt_grp"

If it is a LEFT or RIGHT OUTER JOIN then change it accordingly also. LEFT JOIN or RIGHT JOIN for example.

分享给朋友:
您可能感兴趣的文章:
随机阅读: