我是一个全新的使用psycopg2与postgreSQL数据库交互的新手。我正在尝试执行完整的外部联接,但找不到任何文档来帮助我使用该命令。以下是我在Python 2.6中尝试的内容:
cursor.execute("""
SELECT spl.id,
spl.index,
spl.d_id,
spl.p_id,
spl.pattern,
spe.id,
spe.index,
spe.d_id,
spe.p_id,
FROM s_phrase_label spl
FULL OUTER JOIN s_pattern_extraction spe
ON spl.thread.id = spe.id
AND spl.d_id = spe.d_id,
AND spl.index = spe.index
""")但我一直收到错误。提前感谢您的帮助!
编辑:错误是
ProgrammingError: syntax error at or near "AND"
LINE 14: AND spl.index = spe.index发布于 2013-11-16 07:17:54
您缺少一个逗号:
spl.d_id,
spl.p_id,
spl.pattern //Right here
spe.id,发布于 2013-11-18 17:41:18
不应在WHERE子句中使用的逻辑表达式中间放置逗号:
...
AND spl.d_id = spe.d_id, -- This is an error.
AND spl.index = spe.index
...此外,这与syntax无关:它是一个SQL语法错误。
https://stackoverflow.com/questions/20012187
复制相似问题