删两遍 delete from A where id=id1; delete from B where id=id1;
delete from a,b where id in(select id from (select * from a union all select * from b where id>100) a);
1楼老大 提醒的是a、b表结构相同 ID 自增长 由于以前删除问题可能是不连续的 字段1 int现在把它连接起来给用户看 select 字段1 from a union select 字段1 from b然后需要将用户选中的记录删除另外我发现上面的语句是不能写成select * from a union select * from b
select 字段1 from a union select 字段1 from b 选中的结果来源于这个结果集吧。 那你分别delete就可以了 delete from a where 字段1 in () delete from b where 字段1 in ()
建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
1. 你的 create table xxx .. 语句
2. 你的 insert into xxx ... 语句
3. 结果是什么样,(并给以简单的算法描述)
4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。
delete from A where id=id1;
delete from B where id=id1;
ID 自增长 由于以前删除问题可能是不连续的
字段1 int现在把它连接起来给用户看
select 字段1 from a union select 字段1 from b然后需要将用户选中的记录删除另外我发现上面的语句是不能写成select * from a union select * from b
选中的结果来源于这个结果集吧。
那你分别delete就可以了
delete from a where 字段1 in ()
delete from b where 字段1 in ()