| Author | Topic | 
                            
                                    | skiskiStarting 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 |  | 
       
                            
                       
                          
                            
                                    | vaibhavktiwari83Aged 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 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | skiskiStarting 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 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2010-05-10 : 03:59:59 
 |  
                                          | What is your expected result?MadhivananFailing to plan is Planning to fail |  
                                          |  |  | 
                            
                       
                          
                            
                                    | skiskiStarting 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 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | madhivananPremature 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 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | vaibhavktiwari83Aged Yak Warrior
 
 
                                    843 Posts | 
                                        
                                          |  Posted - 2010-05-10 : 05:58:00 
 |  
                                          | quote:No need of red partand another way using left joinOriginally 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
 
 select 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 nullVaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |  
                                          |  |  | 
                            
                       
                          
                            
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2010-05-10 : 09:08:07 
 |  
                                          | quote:Yes. It was typing errorMadhivananFailing to plan is Planning to failOriginally posted by vaibhavktiwari83
 
 quote:No need of red partand another way using left joinOriginally 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
 
 select 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 nullVaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER 
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | skiskiStarting Member
 
 
                                    15 Posts | 
                                        
                                          |  Posted - 2011-04-05 : 23:37:13 
 |  
                                          | Thanks |  
                                          |  |  | 
                            
                            
                                |  |