我这样编写sql查询
df = pd.read_sql_query('SELECT * FROM hr_dataset WHERE "Performance Score" = "Needs Improvement";', conn)
hr_dataset - table
Performance Score - column
Needs Improvement - searched value
列名和搜索值都包含空格,这就是为什么我必须使用引号,但是这个查询结果有一个错误。
**DatabaseError**: Execution failed on sql 'SELECT * FROM hr_dataset WHERE "Performance Score" = "Needs Improvement";': column "Needs Improvement" does not exist
LINE 1: ...ECT * FROM hr_dataset WHERE "Performance Score" = "Needs Imp...
我应该如何正确地编写这样的查询?
2条答案
按热度按时间izj3ouym1#
请使用下面的查询,“需要改进”用双引号括起来,数据库将其视为列名
eni9jsuy2#
如果是sql server
如果是mysql
如果是postgresql,请尝试
请参阅postgressql的小提琴