在python中第1行的'DESC'附近使用正确的语法
“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”从pandas import * mySQLconnection = mysql.connector.connect(database ='demo',user ='root',password ='9999')cursor =从导入mysql.connector中导入mysql.connector ='''''''' mySQLconnection .cursor()sql =“select * from supplierdatabase DESC”
cursor.execute(SQL)
data1 = cursor.fetchall()print(data1)''一起'''''''''''''''''''''''''''''''''''' '' '' '' .................
mysql.connector.errors.ProgrammingError:1064(42000):您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第1行的“DESC”附近使用正确的语法
看起来您正在尝试订购结果,但尚未说明您想要在哪个列上订购结果。
您需要在SQL语句中添加ORDER BY
子句。例如:
SELECT * FROM supplierdatabase ORDER BY suppliername DESC
您需要使用适合您情况的任何字段名称。