connection = mysql.connector.connect(
host="218.24.35.79",
user="root",
password="1qaz2wsx4rfv",
database="cunchu"
)
# 创建游标
cursor = connection.cursor()
# sql语句
query = "SELECT COUNT(DISTINCT nodes) FROM service"
query = "SELECT nodes FROM service"
cursor.execute(query)
result = cursor.fetchall()
*.关键字:
DISTINCT :用于在 SQL 查询中去除重复数据的关键字
1.查询所有数据
2.查询特定列的数据
3. 条件查询
4. 函数查询
聚合函数如COUNT
、SUM
、AVG
、MIN
和MAX
可以用于对数据进行汇总计算
5. 排序
标签:service,DISTINCT,查询,cursor,select,query,SELECT From: https://www.cnblogs.com/mxleader/p/17441169.html