码迷,mamicode.com
首页 > 编程语言 > 详细

java基础(九章)

时间:2017-06-06 22:20:50      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:desc   select   sel   order by   tor   发送   后台服务   机制   服务器   

一、理解查询的机制

       客户端应用程序(c/s、b/s)向后台服务器的DB发送一条select语句进行查询操作,会将结果集(虚拟表)返回到客户端应用程序

二、select语句

1、查询表中的全部列和行

       select * from 表名

2、根据条件查询数据

       select * from 表名 where 条件

3、查询部分列的数据

              select 列名1,列名2…. from 表名 [where条件]

4、为列名取别名

              方式1:select 列名 as 别名 from 表名[where条件]

              方式2:select 列名 别名 from 表名[where条件]

              方式3:select别名=列名from 表名[where条件]

5、常量列

              select ‘常量值’ as 常量列名 from 表名[where条件]

6、提取表中的行数

              方式1:提取固定的行

                     select  top 行数 列名 from 表名 [where条件]

              方式2:按百分比提取数据行

                select  top 百分比 percent 列名 from 表名 [where条件]

7、查询数据,并排序

              升序:

select 列名列表 from 表名  [where条件]torder by 排序的列名 【asc】

              降序:

select 列名列表 from 表名  [where条件]

order by 排序的列名 desc

8、查询表中某列为空值的数据行

select 列名列表 from 表名 where 列名=’’ or 列名 is null

java基础(九章)

标签:desc   select   sel   order by   tor   发送   后台服务   机制   服务器   

原文地址:http://www.cnblogs.com/alhy/p/6953436.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!