在表A中的数据与表B中的数据有个字段重复,我要删除这些数据该怎么做?我的这个语句
delete from table1 a,table2 b where a.cl1=b.cl1 and a.cl2=b.cl2;
执行出来的结果是删除了表A中的数据还是表B中的数据,或者是两个表中相同的数据都删除了?
delete from table1 a,table2 b where a.cl1=b.cl1 and a.cl2=b.cl2;
执行出来的结果是删除了表A中的数据还是表B中的数据,或者是两个表中相同的数据都删除了?
delete from table1 a where col_name in(select col_name FROM table1 a ,table2 b where a.cl1=b.cl1 and a.cl2=b.cl2);
------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
网上资源: http://tianlesoftware.download.csdn.net
相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
Q Q 群:62697716
----------
1
2
3
4SQL> select * from t2; ID
----------
3
4
5
6SQL> delete from t1,t2 where t1.id=t2.id; --oracle里像你那种语法是会报错的
delete from t1,t2 where t1.id=t2.id
*
ERROR at line 1:
ORA-00933: SQL command not properly ended--下面的例子是删除t1中存在的和t2重复的数据
SQL> delete from t1 where exists(select 1 from t2 where t1.id=t2.id);2 rows deleted.SQL> select * from t1; ID
----------
1
2SQL> select * from t2; ID
----------
3
4
5
6SQL>
这样写
delete from table1 a where a.rowid in (select a.rowid from table1 a,table2 b where a.cl1=b.cl1 and a.cl2=b.cl2)
想删除table2 你自己修改吧