- 子查询:把一个结果集让别人继续分析查询的就叫子查询
- 子查询如果定义了别名,在查询引用时,必须使用别名
-
--子查询定义了别名,引用就必须用别名 select id,n from Person,(select depname as n from Depment ) as d
常用运算符:
- in:表示对多个单列结果进行条件匹配
-
--in例子 select name,age from Person where Age in(select Age from Person where Age < 19) --any例子:与运算符结合使用,大于表示要大于查询到的结果集 select name,age from Person where Age <any(select Age from Person where Age < 19)
exists
-
--exists:判断是否为空,为空false,否则true select * from Person where exists(select * from Depment where id='002') select * from Person where exists( select * from Depment d where d.id = Person.DepID )
将结果集直接在数据库插入一张新表,多数据插入
-
--数据量多插入数据:列必须前后对应 create table person3(id int primary key,name varchar(30),age int, depid varchar(20)) insert into person3( id,name,age,depid) select ID,Name,Age,DepID from person
更新,删除类似
- Sql注入攻击问题,采用参数化传参形式可解决
SqlServer数据库《四》
猜你喜欢
转载自www.cnblogs.com/micc/p/10654737.html
今日推荐
周排行