Author |
Topic |
skiski
Starting Member
15 Posts |
Posted - 2010-05-10 : 02:45:21
|
i need control two table (each table in (id,number,pay)) number and pay and get result each number and pay not exists in table 1thanks |
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-05-10 : 02:59:57
|
Number and pay these are the two tables or what???Not getting you...Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
|
|
skiski
Starting Member
15 Posts |
Posted - 2010-05-10 : 03:20:19
|
Declare @Table1 table(Id int identity,Number INT,pay INT)Declare @Table2 table(Id int identity,Number INT,pay INT)Insert into @Table1 Select 10,1000 union allSelect 20,3000 union allSelect 30,4000 union allSelect 40,5000 union allSelect 50,8000 union allSelect 60,9000 Insert into @Table2 Select 10,1000 union allSelect 30,4000 union allSelect 60,9000 union allSelect 80,6500 union allSelect 200,85 union allSelect 1000,300 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-10 : 03:59:59
|
What is your expected result?MadhivananFailing to plan is Planning to fail |
|
|
skiski
Starting Member
15 Posts |
Posted - 2010-05-10 : 04:33:31
|
Declare @Table1 table(Id int identity,Number INT,pay INT)Declare @Table2 table(Id int identity,Number INT,pay INT)Insert into @Table1 Select 10,1000 union allSelect 20,3000 union allSelect 30,4000 union allSelect 40,5000 union allSelect 50,8000 union allSelect 60,9000 Insert into @Table2 Select 10,1000 union allSelect 30,4000 union allSelect 60,9000 union allSelect 80,6500 union allSelect 200,85 union allSelect 1000,300i need control two table (each table in (id,number,pay)) number and pay and get result each number and pay not exists in table 1thanks |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-10 : 04:49:40
|
select t1.* from @table1 as t1 where not exists(select * from @table2 where t1.id=t2.id and t1.pay=pay)MadhivananFailing to plan is Planning to fail |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-05-10 : 05:58:00
|
quote: Originally posted by madhivanan select t1.* from @table1 as t1 where not exists(select * from @table2 where t1.id=t2.id and t1.pay=pay)MadhivananFailing to plan is Planning to fail
No need of red partand another way using left joinselect t1.* from @table1 as t1 left join @table2 t2 on t1.id = t2.id and t1.pay = t2.paywhere t2.id is null and t2.pay is null Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-10 : 09:08:07
|
quote: Originally posted by vaibhavktiwari83
quote: Originally posted by madhivanan select t1.* from @table1 as t1 where not exists(select * from @table2 where t1.id=t2.id and t1.pay=pay)MadhivananFailing to plan is Planning to fail
No need of red partand another way using left joinselect t1.* from @table1 as t1 left join @table2 t2 on t1.id = t2.id and t1.pay = t2.paywhere t2.id is null and t2.pay is null Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER
Yes. It was typing errorMadhivananFailing to plan is Planning to fail |
|
|
skiski
Starting Member
15 Posts |
Posted - 2011-04-05 : 23:37:13
|
Thanks |
|
|
|