delete from table where 列2 in (select distinct 列2 from table ) and列1=46
长知识! 我想问一下,怎么才能插入大量的记录呢? 比如: 我想插入100条记录 除了用insert into table_name(column1,...) values('dd',...)这样的语句外,没又别的方法了吗? 如果我要插入的记录是又规则的,那又怎么做呢?
是删除重复的记录吗?要保留第一条记录吗?如果不用,楼上的就可以了 j9988(j9988)的删除所有记录,lyyrw(咋暖还寒)的相当于删除第一条记录 '列2 in (select distinct 列2 from table ) and'没意义 条件没有限制好 如果保留一条记录 delete from yourtable where 列2 in (select 列2 from table where 列1=46) and 列1<>46
delete table1 FROM table1 A where EXISTS ( select 1 from table1 where 列1=46 AND 列2=A.列2)DECLARE @I INT SET @I=1 WHILE @I<=100 BEGIN insert into table_name(column1,...,ID) values('dd',...,@I) SET @I=@I+1 END
delete from table where 列2 in (select 列2 from table where 列1=46)
如果不需要知道列1的条件而要删除重复的记录,可以这样 delete from yourtable A where A.列2 in 列1=A.(select 列2 from yourtable where 列1=A.列1) and A.列1 <> (select Max(列1) from yourtable where 列2 = A.列2)to loveandhate(小强) 你的记录是怎么来的,如果也是表里的数据,可以这样 insert into yourtable(field1,fiend2,...) select field1,field2... from sourcetable
如果不需要知道列1的条件而要删除重复的记录,可以这样 delete from yourtable A where A.列2 in (select 列2 from yourtable where 列1=A.列1) and A.列1 <> (select Max(列1) from yourtable where 列2 = A.列2)上面有笔误
我想问一下,怎么才能插入大量的记录呢?
比如:
我想插入100条记录
除了用insert into table_name(column1,...) values('dd',...)这样的语句外,没又别的方法了吗?
如果我要插入的记录是又规则的,那又怎么做呢?
j9988(j9988)的删除所有记录,lyyrw(咋暖还寒)的相当于删除第一条记录 '列2 in (select distinct 列2 from table ) and'没意义 条件没有限制好
如果保留一条记录
delete from yourtable where 列2 in (select 列2 from table where 列1=46) and 列1<>46
FROM table1 A
where EXISTS (
select 1 from table1
where 列1=46 AND 列2=A.列2)DECLARE @I INT
SET @I=1
WHILE @I<=100
BEGIN
insert into table_name(column1,...,ID) values('dd',...,@I)
SET @I=@I+1
END
delete from yourtable A where A.列2 in 列1=A.(select 列2 from yourtable where 列1=A.列1) and A.列1 <> (select Max(列1) from yourtable where 列2 = A.列2)to loveandhate(小强)
你的记录是怎么来的,如果也是表里的数据,可以这样
insert into yourtable(field1,fiend2,...)
select field1,field2... from sourcetable
delete from yourtable A where A.列2 in (select 列2 from yourtable where 列1=A.列1) and A.列1 <> (select Max(列1) from yourtable where 列2 = A.列2)上面有笔误