SQL——select数据查询中的限制和规定

来源:互联网 发布:win10网络共享中心属性 编辑:程序博客网 时间:2024/04/29 13:29
  ------1,select子句的规定  select distinct pcname,logintime from T_StuLogInfo --select中,distinct选项保证重复的行将从结果中去除;--而默认的选择是all选项 ------2,列和基本表的改名操作:使用as  select pcname as computerName from T_StuLogInfo     ------3,集合的并,交,差操作--前提条件:当两个字查询结果的"""""结构"""""完全一致时,可以让这两个子查询执行并,交,差操作。--并,交,差操作的运算符为union,intersect,except--(1)并操作示例:选择日期为'19:28:29'和'19:33:12'select logintime from T_StuLogInfo where LoginTime='19:28:29'union allselect logintime from T_StuLogInfo where LoginTime='19:33:12'--(2)交操作示例:选择日期在19:33:12  和22:32:00  之间的select logintime from T_StuLogInfo where LoginTime>'19:33:12'intersect select logintime from T_StuLogInfo where LoginTime<'22:32:00'--(3)差操作示例:选择日期大于19:33:12  但是不大于22:32:00  之间的select logintime from T_StuLogInfo where LoginTime>'19:33:12'exceptselect logintime from T_StuLogInfo where LoginTime>'22:32:00'    

0 0
原创粉丝点击