+ -
当前位置:首页 → 问答吧 → delete 表名 from 是什么意思

delete 表名 from 是什么意思

时间:2011-12-22

来源:互联网

delete h_assess_emppost from h_assess_emppost,inserted where h_assess_emppost.emp_id=inserted.emp_id and (post_agent=0 or h_assess_emppost.post_id=inserted.post_id)
  insert into h_assess_emppost(emp_id,post_id,post_agent) select inserted.emp_id,inserted.post_id,0 from inserted where inserted.post_id<>''
  insert into sys_user_mstr(user_id,user_name,user_password,user_empid) select inserted.emp_id,inserted.emp_name,'2<(@57',inserted.emp_id from inserted where inserted.emp_id not in (select b.user_id from sys_user_mstr b )


不知道这句话是什么意思

作者: yufei2011   发布时间: 2011-12-22

是SQL SERVER自己的DELETE语法,DELETE 后跟的是后面查询的表别名,给你个简化的语法例子

SQL code
DELETE FROM T1 --FROM可以不写
FROM TB T1
INNER JOIN TB2 T2 ON T1.ID=T2.ID
WHERE T2.VAL='6'

作者: kuqideyupian   发布时间: 2011-12-22

应该是触发器(trigger)里的代码吧?

inserted表是触发器里特有的表,存储的是新增的或修改后的记录.

作者: ap0405140   发布时间: 2011-12-22

delete h_assess_emppost from h_assess_emppost,inserted where h_assess_emppost.emp_id=inserted.emp_id and (post_agent=0 or h_assess_emppost.post_id=inserted.post_id)

两表连接的删除.指定删除表 h_assess_empost 中的内容.

作者: qianjin036a   发布时间: 2011-12-22

SQL code
delete
 h_assess_emppost 
from
 h_assess_emppost,inserted 
where
 h_assess_emppost.emp_id=inserted.emp_id and (post_agent=0 or h_assess_emppost.post_id=inserted.post_id)


insert into
 h_assess_emppost(emp_id,post_id,post_agent) 
select
 inserted.emp_id,inserted.post_id,0 from inserted 
where
 inserted.post_id<>''

insert into
 sys_user_mstr(user_id,user_name,user_password,user_empid) 
select
 inserted.emp_id,inserted.emp_name,'2<(@57',inserted.emp_id 
from
 inserted 
where
 inserted.emp_id not in (select b.user_id from sys_user_mstr b )

作者: fredrickhu   发布时间: 2011-12-22

N条语句 第一条是两表关联删除

后两条是插入语句

作者: fredrickhu   发布时间: 2011-12-22

A 表中 有 1 2 3 
B 表中又 2 3 
删除A表中已存在B表中的数据

delete from A a join B b on a.id=b.id and ...

作者: Net_Java_dram   发布时间: 2011-12-22