#xiaodeng
#python3
#基于SQL和PYTHON的数据库数据查询语句
import pymysql
#1、基本用法
cur.execute("select * from biao")
#2、查询某表中的特定数据,如某制定id和名字的数据
cur.execute("select * from biao where id="XXXX" and name="xxx" ")
#3、统计函数
select count(1) from biao
#4、like模糊查询,比如说统计某姓张的数据,姓张的有多少个数据统计
select count(*) from biao where name like "张%"
#5、统计姓张2个字的人数
select count(*) from biao where name like "张_"
#6、统计杭州籍的同学数量
select count(*) from biao where home like "%杭州%"
#7、查询班上每位学生的年龄
select name, year(now())-year(birthday) as age from biao
#8、mysql查询当天的所有信息:
select * from 表名
where year(regdate) = year(now()) and month(regdate) = month(now()) and day(regdate) = day(now())