【问题标题】:Error:1064, ("You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near错误:1064,(“您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册以获取正确的语法以在附近使用
【发布时间】:2022-01-24 20:54:19
【问题描述】:

我应该改变什么? 这是我的声明:

sql = "SELECT 'housing_median_age', 'median_income' FROM 'california_housing_test' WHERE 'population' = 850"
cur.execute(sql)
result = cur.fetchall()
print(result)

【问题讨论】:

  • 如果您想知道,您看到的那些示例使用的是反引号 (`) 而不是单引号 (')

标签: mysql sql pymysql


【解决方案1】:

MySQL 标识符不带单引号。删除它们:

sql = ""SELECT housing_median_age, median_income
        FROM california_housing_test
        WHERE population = 850"""
cur.execute(sql)
result = cur.fetchall()
print(result)

【讨论】:

    猜你喜欢
    • 2021-08-06
    • 2014-08-17
    • 1970-01-01
    • 2022-01-14
    • 2017-06-01
    • 1970-01-01
    • 2011-08-07
    • 2016-11-06
    相关资源
    最近更新 更多