zoukankan      html  css  js  c++  java
  • SqlServer--查询案例

    use  MyDataBase1

    -- * 表示显示所有列

    -- 查询语句没有加where条件表示查询所有行

    select *from TblStudent

    ---只查询表中的部分列

    select tsid,tsname,tsgender from TblStudent

    --根据条件,只查询部分行(使用where条件筛选部分行显示)

    select * from TblStudent where tsclassId=5

    --为查询结果集中的列起别名

    select tsid as 学生编号,tsname as 学生姓名,tsgender as 性别 from TblStudent

    --也可以这样排列

    select

    tsid as 学生编号,

    tsname as 学生姓名,

    tsgender as 性别

    from TblStudent

    select

    tsid '(学生 编号)', --可以输出空格

    tsname 学生 姓名, --不能输出空格

    tsgender 性别

    from TblStudent

    select

    学生编号=tsid,

    学生姓名=tsname,

    性别=tsgender

    from TblStudent

    select

    学生编号=tsid,

    学生姓名=tsname,

    性别=tsgender,

    婚否='否'

    from TblStudent

    --并不是说select必须配合from一起来使用,可以单独使用select

    select

    当前系统时间=getdate()

    select

    班长='严蒙',

    班花='待定',

    班草='待定',

    班主任='宋词'

    --distinct关键字,针对已经查询出的结果然后去除重复

    select distinct * from TblStudent

    select distinct tsname,tsgender,tsaddress from TblStudent

  • 相关阅读:
    JAVA 高级特性 JDBC
    C3P0 连接池
    JAVA WEB Servlet
    JAVAWEB JSP
    sed 命令
    shell 简单脚本编程
    从首页问答标题到问答详情页
    首页列表显示全部问答,完成问答详情页布局
    制作首页的显示列表
    发布功能完成
  • 原文地址:https://www.cnblogs.com/hao-1234-1234/p/6185223.html
Copyright © 2011-2022 走看看