Sons Table

Category: MS-SQL Server -> Difficult Problems Author: lf20846496 Date: 2004-06-15 13:10:18
 
lf20846496
2004-06-15 13:10:18
Sons of the table-level problem
how to calculate their level ah?
what function can do it?
alvincent2400008
2004-06-15 13:26:42
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)
- Results
/ *
col1
- ---------
04
(the number of rows affected is 1 line)
* /
sajhdklsad
2004-06-15 13:46:01
xiangshuiyoudu () ; () Reputation: 100 Blog Buddy 2007-04-17 14:18:06 Score: 0

select statement inside the loop can be added to it?

-------------------------------------
do not understand what it meant.
cycle can
while <condition>
begin
...
end
bazhahei1130
2004-06-15 14:00:40
preferably in the foreground program or flip-flops to achieve.

If not previously maintenance level, you can check it via a subclass of the parent class to calculate how much class.
wdrs5i
2004-06-15 14:16:32
if ; exists (select 1 from table where column 1 in (select column 2 from table))
print 'presence'
else
print 'does not exist'
xiaoqi_xp_322
2004-06-15 14:34:56
SQL SERVER 2000 is also on the 2005 Lane?
afei0135
2004-06-15 14:43:56
select * from t1 where t1.id not in (select ; id from t2)
hekang8053
2004-06-15 14:52:43
If only one table
table only when his son's id number
how calculated level?
Do eleven compare it
qq461574557
2004-06-15 15:10:29
Column 1 2
01 02
02 04
03 04
To row off table whether the value in column 1 column 2 in the presence of the how to do?
l624491027
2004-06-15 15:22:13
But I want to return a value that does not exist how to do?
nbs519
2004-06-15 15:39:53
such
listed in Table 1
1
01
02
03
05
Table 2
Column 2
01
02
03
04
05
table does not exist in 04 and in Table 2 of the how to find that there
This value was 04 ah?
pkjixian
2004-06-15 15:53:20
tried
it seems wrong
jiangjiayao
2004-06-15 16:07:41
Thank gahade (and the king of encouragement)

kenny_ccp
2004-06-15 16:25:32
select statement which can add a loop do?
lrdeo0758
2004-06-15 16:42:07
Sons table level issues
I want to be compared with the root node to increase the level
I want a select statement but can not seem to find out
so used