tejak123 Posted August 25, 2014 Report Posted August 25, 2014 I have two tables.. I need second table record to be eliminated from first.. I am very something very obvious.. please help me bhaiya TABLE 1 column_1 column_2 Rajesh BENZ Rajesh TOYOTA Suresh BMW Mahesh Nissan Mahesh GM Anirvesh AUDI Anvesh MAZDA TABLE 2 column_1 column_2 Rajesh BENZ Suresh BMW Mahesh GM Anirvesh AUDI Parvesh HONDA I NEED OUTPUT TABLE TO LOOK LIKE OUTPUT TABLE column_1 column_2 Rajesh TOYOTA Mahesh Nissan Anvesh MAZDA
mettastar Posted August 25, 2014 Report Posted August 25, 2014 Union all 2 tables.. then group by two columns having count(*)<2
tejak123 Posted August 25, 2014 Author Report Posted August 25, 2014 Exists condition try cheyyi... ./// NOT EXISTS uh bhaiya.... R u sure.?
tejak123 Posted August 25, 2014 Author Report Posted August 25, 2014 Union all 2 tables.. then group by two columns having count(*)<2 ..// Second table lo records naku vadhu bhaiya.... i need first table with records which are not as same as in second table
SUbba LIngam Posted August 25, 2014 Report Posted August 25, 2014 select * from t1, t2 where t1.col1=t2.col1 and t1.col2 <> t2.col2
LungiLingaraju Posted August 25, 2014 Report Posted August 25, 2014 select * from table1 minus select * from table2
tejak123 Posted August 25, 2014 Author Report Posted August 25, 2014 select * from t1, t2 where t1.col1=t2.col1 and t1.col2 <> t2.col2 ../// i will miss record which is in first.. not in second...
SUbba LIngam Posted August 25, 2014 Report Posted August 25, 2014 select * from t1, t2 where t1.col1=t2.col1 and t1.col2 <> t2.col2 ..///i will miss record which is in first.. not in second... ooh ok, then minus use cheye paina cheppinattu or else not exists use cheye
former Posted August 25, 2014 Report Posted August 25, 2014 select * from table1 minus select * from table2 It should Work. Otherwise You can try with Left Outer Join and sub query like below. SELECT COL1, COL2 FROM ( SELECT A.COL1, A.COL2, B.FLAG FROM TABLE1 A LEFT OUTER JOIN TABLEB B ON B.COL1=A.COL1 AND A.COL2=B.COL2 ) WHERE FALG IS NULL;
loveindia Posted August 25, 2014 Report Posted August 25, 2014 Just use Except operator man SELECT col1 , col2 FROM TABLEA EXCEPT SELECT col1, Col2 FROM TABLEB
libraguy863 Posted August 26, 2014 Report Posted August 26, 2014 SELECT distinct cols FROM AunionSELECT distinct cols FROM B
Sambadu Posted August 26, 2014 Report Posted August 26, 2014 select t1.* from t1 left join t2 on t1.col2 = t2.col2 where t2.col1 is null test kuda chesina.. work chestundi chudu.. pakka.
ramu Posted August 26, 2014 Report Posted August 26, 2014 Select * from table1 t1 where not exists (select * from table2 t2 where t1.column1 = t2.column_1 and t1.column2 = t2.column_2)
Recommended Posts