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)

    --排除表中与岁的人

  • 相关阅读:
    《飞得更高孙正义传》成为亚洲首富肯定有原因
    AutoController通用自动增删查改
    Silverlight学习笔记第一季(3)扯扯ComboBox
    Silverlight学习笔记第一季(1)DataGrid
    菜鸟混社区之如何看待社区的口水战?
    局部化页面和效率CMS实践系列总结
    图片猜成语(思维@娱乐)
    接口+泛型强大的Repository
    Silverlight学习笔记第一季(2)Listbox横向绑定数据
    poj 2954 Triangle (pick 定理 的应用 )
  • 原文地址:https://www.cnblogs.com/wwJ0312/p/4441621.html
Copyright © 2011-2022 走看看