mysql数据库查询.docVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
最全的mysql查询语句(审精) null, 名字, 宠物 --基本查询 select * from pet --列出指定的列 select name, owner form pet --直接进行算术运算,对字段起别名 select sin(1+2) as sin --where条件 select * from pet where (birth1980 and species=dog) or species=bird --对null的条件 select * from pet where sex is not null --所有名字第四位是n的宠物信息是 select * from pet where owner like ___n% --所有主人名叫gwen或benny的宠物 select * from pet where owner in (gwen , benny) --查询出生日期在90年代是宠物,相当与? ?= and??= select * from pet where birth between 1990 and 1999 --按主人姓名排序,相同的按宠物姓名倒序排列 select * from pet order by owner, name desc --查询性别为公的宠物,按生日倒序排列 select * from pet where sex=m order by birth desc --char_lenngth()返回的字符的长度,length()返回字节长度 SELECT owner,length(owner),char_length(owner) FROM pet p; --列出养有宠物狗的人名 select distinct owner from pet where species=dog --用两种方法查询出所有狗和猫的名字、出生年份、出生月份 select name, left(birth,4) as year, mid(birth, 6, 2) as month from pet where species=dog or species=cat select name, year(birth) as year, month(birth) as month from pet where species in(dog,cat) --查询所有名字中存在字母e的人,将他们养的宠物按类别、年龄排序 select name, species, birth from pet where owner like %e% order by species,birth desc --数字函数 select round(2.345,2), truncate(2.345,2), mod(323,5) --日期函数 select now(), curdate(), curtime() select adddate(2007-02-02, interval 31 day) --求出所有宠物的年龄 select name,birth, truncate(datediff(now(),birth)/365,0) as age1, year(now())-year(birth) - (dayofyear(birth)dayofyear(now())) as age2 from pet --分组函数 select min(birth),max(birth),avg(birth),count(*),count(sex), sum(birth) from pet --每种宠物各有几只 select species,count(*) from pet group by species --查询年龄最大的宠物的信息 select * from pet where birth = ? ?? ?(select max(birth) from pet) --每年各出生了几只宠物 select year(birth), count(*) from pet group by year(birth) --鸟和猫的性别比例 select species, sex, count(*) from pet where species in (cat,bird) group by species, sex --各种宠物年龄的和 select species, sum(truncate(datediff(now(),birth)/365,0)) as SumAge from pet group by species --数量大于1的宠物种类 select species, count(*) as c

文档评论(0)

ea238982 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档