5.数据检索

--数据检索--
语法:
--select 字段列表/* from 表列表where 条件(not and or)

--1.查询所有学员信息
select * from Student
--2.查询所有女学员信息
select * from Student where Sex=‘女‘
--3.多条件查询
select * from Student where Sex=‘女‘ and ClassId=‘6‘
--4.指定查询的列
select StudentName,Sex,Phone,Address from Student where Sex=‘女‘ and ClassId=‘6‘
select Student.StudentName,Student.Sex,Student.Phone,Student.Address from Student where Sex=‘女‘ and ClassId=‘6‘
--5.指定列标题as可以指定列标题,但是它可以省略,这种操作纯粹是得到结果集之后,在视图中的另外一种显示方式,与查询无关
select StudentName as 姓名,Sex 性别,电话=Phone,Address from Student where Sex=‘女‘ and ClassId=‘6‘
--6.添加常量列
select StudentName as 姓名,Sex 性别,电话=Phone,Address,‘广州‘ as 城市 from Student where Sex=‘女‘ and ClassId=‘6‘

--select有两种功能
1.查询
2.输出:以结果集的形式进行输出的
select 1

--
-使用top提取记录,top可以提取指定数量的记录,也可以使用百分比
--它不是四舍五入,而是Ceiling
--select CEILING(0.999)
select top 2 StudentName as 姓名,Sex 性别,电话=Phone,Address,‘广州‘ as 城市 from Student where Sex=‘女‘ and ClassId=‘6‘
select top 80 percent StudentName as 姓名,Sex 性别,电话=Phone,Address,‘广州‘ as 城市 from Student where Sex=‘女‘ and ClassId=‘6‘
--使用distinct来过滤重复记录.它所说的重复记录不是指表的原始记录,而是通过查询得到的结果集,只有查询的结果集的每一个字段值都一样,才认为是重复记录
select distinct  LoginPwd,Sex from Student
时间: 2024-08-07 21:20:48

5.数据检索的相关文章

SQL从入门到基础 - 04 SQLServer基础2(数据删除、数据检索、数据汇总、数据排序、通配符过滤、空值处理、多值匹配)

一.数据删除 1. 删除表中全部数据:Delete from T_Person. 2. Delete 只是删除数据,表还在,和Drop Table(数据和表全部删除)不同. 3. Delete 也可以带where子句来删除一部分数据:Delete from T_Person where FAge>20. 二.数据检索 1. 执行备注中的代码创建测试数据表. 2. 简单的数据检索:select *from T_Employee(*表示所有字段) 3. 只检索需要的列:select FNumber

数据检索,top,Distinct去除重复记录

--数据检索--语法:--select 字段列表/* from 表列表 where 条件----查询所有学员信息select * from student--带条件的查询select * from Student where Sex='女'select * from Student where Sex='男'--查询指定的列select StudentNo,StudentName,Sex,Address,Phone from Student--设置查询 结果集--虚拟表 的列名称select S

Hibernate的检索及五种数据检索方式

检索数据时的 2 个问题 1). 不浪费内存:当 Hibernate 从数据库中加载 Customer 对象时, 如果同时加载所有关联的 Order 对象, 而程序实际上仅仅需要访问 Customer 对象, 那么这些关联的 Order 对象就白 白浪费了许多内存. 2). 更高的查询效率:发送尽可能少的 SQL 语句 类级别的检索策略 2. 类级别的检索策略:(主要掌握 load 方法和 get 方法的区别!) 1). 类级别可选的检索策略包括立即检索和延迟检索, 默认为延迟检索 ①. 立即检

嘿嘿,今天学习啦数据检索啦

嘿嘿,今天是周二啦,昨天开始初步学习啦数据库,那么今天我们就是详细的学习啦数据库的检索啦,或许今天学习的比较多,但是我感觉还是可以的啦,最重要的是我可以接受的啦,这个是最值得庆幸的啦,现在每天学习完在这里总结成为了我的习惯,在总结中我会有更多新的发现,或许就像今天一位友友和我说的,认为我现在在培训,哪里还有时间写博客那,我想说的是,我的确把今天学习的知识都熟悉熟悉,然后自己按照老师讲的操作一遍后才来写的博客,也许还有人会问?操作一遍都可以没事情啦吗,今天学习的知识就掌握啦吗,当然不是啦,我们现在

【转载】使用Lucene.NET实现数据检索功能

1.索引的管理 //指定索引库文件存放文件位置 FSDirectory directory = FSDirectory.Open(new DirectoryInfo(this.IndexDataDir), new NativeFSLockFactory()); //判断索引文件目录是否存在 bool isExist = IndexReader.IndexExists(directory); if (isExist) { if (IndexWriter.IsLocked(directory)) {

学习哈希及哈希在大数据检索和挖掘中的应用

http://cs.nju.edu.cn/lwj/conf/CIKM14Hash.htm Learning to Hash with its Application to Big Data Retrieval and Mining Overview Nearest neighbor (NN) search plays a fundamental role in machine learning and related areas, such as information retrieval an

【高德地图API】从零开始学高德JS API(四)搜索服务——POI搜索|自动完成|输入提示|行政区域|交叉路口|自有数据检索

摘要: 地图服务,大家能想到哪些?POI搜素,输入提示,地址解析,公交导航,驾车导航,步行导航,道路查询(交叉口),行政区划等等.如果说覆盖物Marker是地图的骨骼,那么服务,就是地图的气血.有个各种各样的地图服务,我们的地图应用才能变得有血有肉,活灵活现. 第四篇拆成了几个要点,本篇主要讲搜索服务.包括周边搜索,关键词搜索,范围搜索,搜索提示(自动完成,输入提示),行政区域,交叉路口,检索自有数据(云图). demo:http://zhaoziang.com/amap/zero_4_1.ht

DataTable数据检索的性能分析[转]

原文链接 作者写得非常好,我学到了许多东西,这里只是转载! 我们知道在.NET平台上有很多种数据存储,检索解决方案-ADO.NET Entity Framework,ASP.NET Dynamic Data,XML, NHibernate,LINQ to SQL 等等,但是由于一些原因,如平台限制,比如说必须基于.NET Framework2.0及以下平台:遗留的或者第三方数据接口采用的就是DataTable等等,仍然需要使用DataTable作为数据存储结构.另一方面DataTable比较容易

20-7数据检索

-----------------------数据检索(查询)-------------------------- --*表示显示所有列 --查询语句没有加where条件表示查询所有行 select * from TblStudent --只查询表中的部分列 select tsid,tsname,tsgender from TblStudent --根据条件,只查询部分行(使用where条件筛选部分行显示) select * from TblStudent where tsclassid=5 -