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)

    --排除表中与岁的人

  • 相关阅读:
    HTML基础
    JavaScript基础
    J2EE技术(六)——JSP
    2011.2—至今年度总结
    J2EE技术(二)——JDBC
    DRP项目总结(一)——项目简介
    CSS基础
    J2EE技术(五)——EJB
    J2EE技术(三)——JMS
    J2EE技术(四)——JavaMail
  • 原文地址:https://www.cnblogs.com/wwJ0312/p/4441621.html
Copyright © 2011-2022 走看看