20-7数据检索

-----------------------数据检索(查询)--------------------------

--*表示显示所有列
--查询语句没有加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  学生编号,
     tsname  学生姓名,
     tsgender  学生性别 
from TblStudent

或
select 
     tsid  '(学生 编号)',
     tsname  学生姓名,
     tsgender  学生性别 
from TblStudent

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


-------可增加任意列
select 
      学生编号=tsid,
     学生姓名=tsname,
     学生性别=tsgender,
     婚否='' 
from TblStudent


--并不是说select必须配合from使用,可以单独使用
select 
  当前系统时间=getdate()
原文地址:https://www.cnblogs.com/Strugglinggirl/p/7198489.html