首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

父子表解决办法

2012-01-18 
父子表父子表中级别问题怎么计算它们的级别啊?有什么函数可以做到吗?[解决办法]最好是在前台程序或触发器

父子表
父子表中级别问题
怎么计算它们的级别啊?
有什么函数可以做到吗?

[解决办法]
最好是在前台程序或触发器里实现.

如果以前没有维护级别,可通过某一子类查它父类有多少级来计算.
[解决办法]
if exists(select 1 from 表 where 列1 in (select 列2 from 表))
print '存在 '
else
print '不存在 '
[解决办法]
SQL SERVER 2000还上2005里的?
[解决办法]
select * from t1 where t1.id not in (select id from t2)
[解决办法]
create table #t1(col1 varchar(10))
insert into #t1
select '01 '
union select '02 '
union select '03 '
union select '05 '

create table #t2(col1 varchar(10))
insert into #t2
select '01 '
union all select '02 '
union all select '03 '
union all select '04 '
union all select '05 '

select * from #t2
where not exists(select 1 from #t1 where #t1.col1=#t2.col1)
--结果
/*
col1
----------
04
(所影响的行数为 1 行)
*/
[解决办法]
xiangshuiyoudu() ( ) 信誉:100 Blog 加为好友 2007-04-17 14:18:06 得分: 0


select 语句里面可以加循环吗?

-------------------------------------
不明白什么意思.
循环可以用
while <条件>
begin
...
end

热点排行
Bad Request.