查询表中已删除id的方法
来源:互联网 发布:腾讯mac 编辑:程序博客网 时间:2024/05/09 13:21
方法一: 创建一个满足需求的很大的View
create view v_number --创建一个view,里面存放1到9999的数据,如果需要更大可以根据自己的情况修改
as
select number from
(
select t1.b+t2.b*10+t3.b*100+t4.b*1000 number
from
(
select 0 b union all select 1 b union all select 2 b union all
select 3 b union all select 4 b union all select 5 b union all
select 6 b union all select 7 b union all select 8 b union all select 9 b
) t1,
(
select 0 b union all select 1 b union all select 2 b union all
select 3 b union all select 4 b union all select 5 b union all
select 6 b union all select 7 b union all select 8 b union all select 9 b
) t2,
(
select 0 b union all select 1 b union all select 2 b union all
select 3 b union all select 4 b union all select 5 b union all
select 6 b union all select 7 b union all select 8 b union all select 9 b
) t3,
(
select 0 b union all select 1 b union all select 2 b union all
select 3 b union all select 4 b union all select 5 b union all
select 6 b union all select 7 b union all select 8 b union all select 9 b
) t4
) t5
where number<>0
--用左外连接找到clothid中的cid不在v_number中的数
select number
from v_number left outer join YWXX on number = YWID
where YWID is null and number <(select max(YWID ) from YWXX )
order by number
方法二:
创建一个临时表
declare @temptable table(a int)
declare @char varchar(1000),@i int,@num int
set @num=(select max(YWID) from YWXX)
set @i=1
while @i<=@num
begin
insert @temptable values (@i)
set @i=@i+1
end
select a from @temptable where a not in (select YWID from YWXX)
- 查询表中已删除id的方法
- mongoose中通过-id查询的方法
- 删除所有链接\批量删除DB\查询某个用户进程ID执行的操作
- 删除所有链接\批量删除DB\查询某个用户进程ID执行的操作
- 查询及删除重复记录的方法
- 查询及删除重复记录的方法
- 查询及删除重复记录的方法
- 查询及删除重复记录的方法
- 查询及删除重复记录的方法
- 查询及删除重复记录的方法
- 查询及删除重复记录的方法
- 查询及删除重复记录的方法
- 查询及删除重复记录的方法
- 查询与删除重复记录的方法
- 查询及删除重复记录的方法
- 查询及删除重复记录的方法
- 封装cookie的添加,删除,查询方法
- mongodb的id查询
- 谈些非技术的。。。
- 我抓住了 CSDN Blog 的小尾巴
- 天气预报小偷
- java开发代码规范
- 野马奔腾而出,Java SE 6 正式版发布
- 查询表中已删除id的方法
- 【原创】samba服务--基于窗口方式配置...
- 正则表达式全部符号解释
- Repeater或者DataList中如果要使用Custom User Control可以使用如下方法
- 远程备份数据库
- 12月7日——培训第15天
- 寻找我的女孩儿。。。
- 12月8日——培训第16天
- 下面代码实现将 GridView 导出到 Excel文件中。