Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何查询Mysql游标?_Python_Mysql_Cursor - Fatal编程技术网

Python 如何查询Mysql游标?

Python 如何查询Mysql游标?,python,mysql,cursor,Python,Mysql,Cursor,我已经将数据提取到mysql游标中,现在我想对游标中的一列求和。 有什么BIF或我能做的任何事情使它工作吗 db = cursor.execute("SELECT api_user.id, api_user.udid, api_user.ps, api_user.deid, selldata.lid, api_selldata.sells FROM api_user INNER JOIN api_user.udid=api_selldata.udid AND api_user.pc='com'"

我已经将数据提取到mysql游标中,现在我想对游标中的一列求和。 有什么BIF或我能做的任何事情使它工作吗

db = cursor.execute("SELECT api_user.id, api_user.udid, api_user.ps, api_user.deid, selldata.lid, api_selldata.sells
FROM api_user
INNER JOIN api_user.udid=api_selldata.udid AND api_user.pc='com'")

我猜想答案是,不能在查询中包含SUM之类的聚合函数,除非通常可以通过添加GROUP by子句来保证SUM中包含的所有行的非聚合列的值都相同


聚合函数有效地将多行上的一列压缩为单个值,这无法对非聚合列执行,除非SQL知道它们保证对所有考虑的行具有相同的值,而GROUP BY将执行此操作,但这可能不是您想要的。

请将编辑后的列编辑为需要求和的列。使用SumColumnName我需要此列api_selldata.sells的总和。我试着用sumapi_selldata.sells这样做,但它对我不起作用:\n不起作用,因为你收到了错误消息,或者你得到了错误的结果?你提供的信息越多,就越有可能有人能提供帮助,所以请报告当前的结果。是的!这个答案解决了我的问题。谢谢大家的帮助