Author |
Topic |
gongxia649
So Suave
344 Posts |
Posted - 2006-04-11 : 10:03:06
|
create table t1 (pnid int, group_pn int)insert into t1 values (1, 48)insert into t1 values (2, 49)create table t2 (pnid int, group_pn int)insert into t2 values (3, 48)insert into t2 values (4, 50)i need to find pnid where the group_pn is not in t2 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
gongxia649
So Suave
344 Posts |
Posted - 2006-04-11 : 10:08:36
|
thank u so much for your help |
|
|
gongxia649
So Suave
344 Posts |
Posted - 2006-04-11 : 10:10:46
|
but it doesnt work |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-11 : 10:12:26
|
quote: Originally posted by gongxia649 but it doesnt work
Did you get error?Did you get wrong result?MadhivananFailing to plan is Planning to fail |
|
|
gongxia649
So Suave
344 Posts |
Posted - 2006-04-11 : 10:13:35
|
(1 row(s) affected)(1 row(s) affected)Server: Msg 107, Level 16, State 3, Line 10The column prefix 't1' does not match with a table name or alias name used in the query. |
|
|
gongxia649
So Suave
344 Posts |
Posted - 2006-04-11 : 10:14:14
|
i actally tried that way before. but it doesnt work. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-11 : 10:18:14
|
Well.Try thisselect T.pnid from t1 T where not exists(select * from t2 where pnid=T.pnid)MadhivananFailing to plan is Planning to fail |
|
|
gongxia649
So Suave
344 Posts |
Posted - 2006-04-11 : 10:22:20
|
its showing 1 and 2. It should show just 2. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-11 : 10:42:20
|
Well. Ignore my previous answersThis should do what you want select T.pnid from t1 T where not exists(select * from t2 where group_pn=T.group_pn)MadhivananFailing to plan is Planning to fail |
|
|
|