zoukankan      html  css  js  c++  java
  • SQL查询语句练习及相关代码

    select *from xueshengxinxi where shengao=164

    select *from xueshengxinxi where nianling !=23

    --子查询:就是使用查询语句查询一列数据出来,然作为其他查询的查询条件参数来使用

    --查询身高不在年龄是岁的人的身高范围之内的信息

    select *from xueshengxinxi where nianling =22

    select *from xueshengxinxi where shenfenzheng not in (178,161,162)

    --名字叫Add的人中的年龄比no=5的Ddd的那个人的年龄大岁的人的信息

    select *from xueshengxinxi where shengao not in (select shengao from xueshengxinxi where nianling=22)(这句话是一个整体)

    select *from xueshengxinxi where nianling-(select nianling from xueshengxinxi where no =5)>3 and name='Add'

    --         姓名表中              年龄减去no=5的人大于并且名字叫Add的人

    select top 3 *from xueshengxinxi

    --查询表中前人的信息top(前多少行)

    select distinct name from xueshengxinxi

    --查询不重名的人信息distinct(去重)

    select *from xueshengxinxi order by tizhong asc

    --依表中体重为条件进行升序排序(轻在前,重在后) asc (升序)

    select *from xueshengxinxi order by tizhong desc

    --依表中体重为条件进行降序排序(重在后,轻在前) desc(降序)

    select *from xueshengxinxi order by nianling asc,shengao desc

    --先依表中年龄进行排序当遇到想的的年龄值时再以身高为条件对相等的值进行降序排序

    select name from xueshengxinxi group by name

    --建立以name 为条件的分组(只能显示一列并且只有一列,对那个列分组就只显示那一列)

    select *from xueshengxinxi where nianling in (22,23)

    select *from xueshengxinxi where nianling=22 or nianling=23

    --二者意思一样但是表达方式不同都是选出表中年龄在到之间的人

    select *from xueshengxinxi where nianling not in (22,23)

    --排除表中与岁的人

  • 相关阅读:
    Spring Cloud
    如何修改容器时间而不改变宿主机时间?
    消息中间件 RabbitMQ 入门篇
    CentOS7下NFS服务安装及配置固定端口
    查看ssh有没有被黑的IP
    JVM常用命令和性能调优建议
    nfs高可用
    kafka集群部署以及单机部署
    OSGI企业应用开发(十三)OSGI Web应用开发(二)
    OSGI企业应用开发(十二)OSGI Web应用开发(一)
  • 原文地址:https://www.cnblogs.com/wwJ0312/p/4441621.html
Copyright © 2011-2022 走看看