在使用Redshift Python连接器时如何使用WHERE关键字过滤查询结果?

0

【以下的问题经过翻译处理】 我正在使用Redshift的Python连接器来查询我的数据库。查询工作得很可预测,直到我尝试使用WHERE关键字。例如,运行查询:

"select * from dev.public.test_host WHERE first_column = git"

返回以下错误:

redshift_connector.error.ProgrammingError: {'S': 'ERROR', 'C': '42703', 'M': 'column "git" does not exist in test_host', 'F': '../src/pg/src/backend/parser/parse_expr.c', 'L': '1523', 'R': 'transformColumnRef'}

另一个例子:"select * from information_schema.tables WHERE table_name = test_host" 返回以下错误:

redshift_connector.error.ProgrammingError: {'S': 'ERROR', 'C': '42703', 'M': 'column "test_host" does not exist in tables', 'F': '../src/pg/src/backend/parser/parse_expr.c', 'L': '1523', 'R': 'transformColumnRef'}

当在Redshift查询编辑器v2中运行这些查询时,它们返回正确的答案。在没有'where'部分的情况下运行时也返回正确答案。请帮帮我。

1개 답변
0

【以下的回答经过翻译处理】 你需要在你要筛选的字符串周围加上单引号,如下所示:

= 'git'

而不是

= git

profile picture
전문가
답변함 5달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인