sql最简单的查询语句
-- 2 **************************************************** -- 最简单的查询语句
-- 2.1 --------------------------------------------------
-- 使用 select 语句查询表中的数据
-- SELECT * FROM table_name
use pubs
-- 切换当前数据库 select * from authors
-- 2.2 --------------------------------------------------
-- 使用完全限定名称
-- SELECT * FROM [server_name].[database_name].[owner].[object]
select * from Northwind.dbo.Employees
select * from Northwind..Orders
-- 2.3 --------------------------------------------------
-- 查询数据表中指定的列 -- SELECT column_1,column_2 FROM table_name
select * from authors select au_id,au_lname,au_fname,city from authors
-- 2.4 --------------------------------------------------
-- 使用 where 字句筛选指定的行
-- SELECT * FROM table_name WHERE <search_condition>
select * from jobs
select * from jobs where job_id=7
select * from authors
select * from authors where au_lname = 'White'
-- 2.5 --------------------------------------------------
-- where 字句中的搜索条件
-- 比较操作符 =, <, >, <=, >=, <>
-- 字符串比较符 like, not like
-- 逻辑操作符 and, or, not
-- 值的域 between, not between
-- 值的列表 in, not in
-- 未知的值 is null, is not null
select * from jobs where job_id >=10
select * from jobs where job_desc like '%manager%'
select * from jobs where job_id >=10 AND job_desc like '%manager%'
select * from jobs where min_lvl between 100 and 150
select * from jobs where job_id in (1,3,5,7,11,13)
select * from discounts where stor_id is null
-- 2.6 --------------------------------------------------
-- 使用 like
-- % 代表 0 个或多个字符串
-- _ 代表任何单个的字符
-- [] 代表指定区域内的任何单个字符
-- [^] 代表不在指定区域内的任何单个字符
select * from authors where au_lname like 'G%'
select * from authors where address like '%Av.%'
select * from authors where au_fname like 'A__'
select * from authors where au_fname like '[AS]%'
select * from authors where au_lname like 'S[^m]%'
-- 2.7 --------------------------------------------------
-- 格式化结果集
-- order by 排序结果集
-- distinct 消除重复的行
-- as 改变字段的名字
select * from employee order by fname
select * from employee order by hire_date desc
select distinct type from titles
select au_id,au_lname as [Last Name],au_fname as [First Name] from authors
sql最简单的查询语句的更多相关文章
- oracle学习 第一章 简单的查询语句 ——03
1.1最简单的查询语句 例 1-1 SQL> select * from emp; 例 1-1 结果 这里的 * 号表示全部的列.它与在select 之后列出全部的列名是一样的.查询语句以分号( ...
- T-SQL:SQL Server-数据库查询语句基本查询
ylbtech-SQL Server-Basic:SQL Server-数据库查询语句基本查询 SQL Server 数据库查询语句基本查询. 1,数据库查询语句基本查询 数据库 SQL Serv ...
- 一道sql面试题(查询语句)
一道sql面试题(查询语句) id name age 1 a 11 2 b 11 3 c 12 4 d 13 5 e ...
- Oracle SQL:select各类查询语句总结
SQL查询语句总结 数据查询语言:即DML(Data Mannipulation Language)数据操纵语言,用于查询.操纵数据表资料行 本手册所有示例引用表均以TIPTOP GP ERP数据库 ...
- 简单oracle查询语句转换为mongo查询语句
可以将简单的单表查询语句转换成Mongo过滤条件 列: 1. db.demo.aggregate([ {"$match": {"$and": [{"p ...
- SQL中的DQL查询语句
目录 1. DQL:查询语句 排序查询 聚合函数 分组查询 分页查询 2. 约束 3. 多表之间的关系 4. 范式 DQL:查询语句 1. 排序查询 语法:order by 子句 order by 排 ...
- sql server 常用的查询语句
最近在加强sql 语句的学习,整理一下基本语法,现在记录下 select * from dbo.cangku where city='河南' select distinct(city), cangk ...
- 逆袭之旅DAY13.东软实训.Oracle.简单的查询语句.限制.排序
2018-07-09 21:34:00 一.简单查询: .查询数据表的所有列: SELECT * FROM 表名; SELECT 列名,列名.... FROM 表名; .起别名: SELECT 列名 ...
- MySQL、Oracle和SQL Server的分页查询语句
假设当前是第PageNo页,每页有PageSize条记录,现在分别用Mysql.Oracle和SQL Server分页查询student表. 1.Mysql的分页查询: SELECT * FROM s ...
随机推荐
- [源码]K8 Cscan模块 C#获取内网主机IP/机器名/Banner/网页标题源码
[原创]K8 Cscan 大型内网渗透自定义扫描器 https://www.cnblogs.com/k8gege/p/10519321.html Cscan简介:何为自定义扫描器?其实也是插件化,但C ...
- RabbitMQ常见错误1
java.lang.IllegalStateException: Invalid configuration: 'exchange' must be non-null. at com.rabbitmq ...
- UFLDL 教程学习笔记(二)反向传导算法
UFLDL(Unsupervised Feature Learning and Deep Learning)Tutorial 是由 Stanford 大学的 Andrew Ng 教授及其团队编写的一套 ...
- Intellij-忽略其他编译错误,运行当前文件
在使用Intellij IDEA的时候,有时候想在项目中写个main()方法或者单元测试测试个功能,但是有其他文件编译出错IDEA就提示我说不能运行,很是烦恼. 能不能像Eclipse一样呢,其他编译 ...
- Spring Cloud 微服务中搭建 OAuth2.0 认证授权服务
在使用 Spring Cloud 体系来构建微服务的过程中,用户请求是通过网关(ZUUL 或 Spring APIGateway)以 HTTP 协议来传输信息,API 网关将自己注册为 Eureka ...
- Android 源码分析01_AsyncTask
[参考文献] http://blog.csdn.net/singwhatiwanna/article/details/17596225 /* * Copyright (C) 2008 The Andr ...
- Firefox37.0.1+selenium 2.53+python3.6打开浏览器时报错NameError: name 'basestring' is not defined
环境:Win7 Firefox浏览器版本37.0.1 Python36 Selenium2.53.0 在Pycharm里执行以下3行脚本: from selenium i ...
- 又拍云 Node.js 实现文件上传、删除
Node.js 服务端 使用 Node.js + Express.js 实现 服务端 const express = require("express"); const app = ...
- Docker基本命令汇总
Docker的三大核心概念:镜像.容器.仓库 镜像:类似虚拟机的镜像.用俗话说就是安装文件. 容器:类似一个轻量级的沙箱,容器是从镜像创建应用运行实例,可以将其启动.开始.停止.删除.而这些容器都是相 ...
- 使用Pabot并行运行RF案例
一.问题引入 在做接口自动化时随着案例增多,特别是流程类案例增多,特别是asp.net的webform类型的项目,再加上数据库校验也比较耗时,导致RF执行案例时间越来越长,就遇到这样一个问题,705个 ...