【问题标题】:i don't know what is wrong with this syntax我不知道这个语法有什么问题
【发布时间】:2020-08-09 07:45:04
【问题描述】:
cur = mysql.connection.cursor()
cur.execute("""Select Qid, Username, Question, StdName, SubName, PostDate, AnsCount from user
            inner join Textual_Question, subjects, standard where
            Textual_Question.Qid = {} and
            user.Uid = Textual_Question.Uid and
            Textual_Question.Subject = subjects.Subkey and
            ​Textual_Question.standard =standard.StdKey""".format(Qid))

(1064, "您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,了解在 '} 和\n user.Uid = Textual_Question.Uid 和\n Textual_Question 附近使用的正确语法。第 3 行的主题")

【问题讨论】:

  • 不要使用逗号样式的连接,并且绝对不要将它们与常规连接混合(尽管这与您的具体问题无关)。如需更多帮助,请参阅meta.stackoverflow.com/questions/333952/…
  • 我猜你错过了右括号。

标签: mysql flask


【解决方案1】:

我猜你错过了右括号。

cur.execute("""Select Qid, Username, Question, StdName, SubName, PostDate, AnsCount from user
                inner join Textual_Question, subjects, standard where
                Textual_Question.Qid = '{0}' and
                user.Uid = Textual_Question.Uid and
                Textual_Question.Subject = subjects.Subkey and
                ​Textual_Question.standard = standard.StdKey""".format(Qid))

【讨论】:

    猜你喜欢
    • 2014-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 2015-09-11
    相关资源
    最近更新 更多