我需要删除从子查询中获取的少数记录。
假设EMP
表格中包含EMPNAME
,EMPSALARY
列,而主键是EMPNAME,EMPSALARY
的组合。
delete from emp
where exists (
select *
from EMP ***** //query which fetch few records from EMP table);
以上查询无效。
感谢您的帮助。
答案 0 :(得分:2)
你可以直接在where子句中给出条件
delete from emp where <conditions>;
否则你可以这样做
DELETE FROM Table1 T1
WHERE EXISTS (SELECT column1 FROM table2 T2
WHERE T1.column1 = T2.column1
AND T1.Column2 = T2.column2 );
答案 1 :(得分:1)
您的查询看起来像
delete from emp
from emp e
where exists (select *
from EMP
WHERE e.EMPNAME = EMPNAME
AND e.EMPSALARY = EMPSALARY
AND <another Condition>) --<-- Condition on which you want to delete rows
答案 2 :(得分:0)
您可以使用以下查询:
delete from emp
where primary_key_column_name IN
(
select primary_key_column_name from EMP where <your conditions>
);
或
delete from emp where <your conditions>;