sql最简便的询问语句

— _   代表任何单个的字符

— 格式化结果集

— 切换当前数据库 select * from authors

— order by  排序结果集

— 2.2 ————————————————–

select * from jobs where job_id >=10 AND job_desc like ‘%manager%’

— 2.7 ————————————————–

select * from authors select au_id,au_lname,au_fname,city from
authors

— 2.6 ————————————————–

select * from authors where au_lname = ‘White’

select * from jobs where job_id in (1,3,5,7,11,13)

— 使用 like

select * from jobs where job_id=7

— distinct  消除重复的行

— SELECT * FROM
[server_name].[database_name].[owner].[object]

select * from Northwind.dbo.Employees

— [^] 代表不在钦点区域内的别样单个字符

— SELECT * FROM table_name

select * from discounts where stor_id is null

— as        改变字段的名字

— 字符串比较符  like, not like

— 使用完全限定名称

— 值的列表      in, not in

— 2.4 ————————————————–

— %   代表 0 个或八个字符串

select * from authors where address like ‘%Av.%’

select * from jobs where job_id >=10

— 2.3 ————————————————–

select * from jobs where min_lvl between 100 and 150

— 2.1 ————————————————–

— 值的域        between, not between

— 使用 where 字句筛选内定的行

— 逻辑操作符    and, or, not

select * from employee order by fname

select * from authors

select * from authors where au_fname like ‘A__’

select * from authors where au_fname like ‘[AS]%’

select * from employee order by hire_date desc

select * from jobs

select * from authors where au_lname like ‘S[^m]%’

— 比较操作符    =, <, >, <=, >=, <>

— 使用 select 语句查询表中的数据

select * from authors where au_lname like ‘G%’

— 未知的值      is null, is not null

select au_id,au_lname as [Last Name],au_fname as [First Name]
from authors

— 2.5 ————————————————–

— []  代表钦赐区域内的任何单个字符

— SELECT * FROM table_name WHERE <search_condition>

select distinct type from titles

select * from jobs where job_desc like ‘%manager%’

— where 字句中的搜索条件

use pubs

— 2
****************************************************
— 最简单易行的询问语句

— 查询数据表中钦定的列 — SELECT column_1,column_2 FROM table_name

select * from Northwind..Orders

相关文章