shan_cool Posted August 9, 2006 Share Posted August 9, 2006 Hi all, I have two tables "table1" and "table2" and "id" is the field common to both the tables.. All id data will be in "table1" say 10,20,30,40,50,60 . but only few of them will get stored in "Table2" say 20 ,40.Now i need the retrieve the values of id's that are in "table1" and not in "table2" Ex: 10,30,50,60.My query is"Select h1.id from table1 h1,table2 h2 where h1.id Not In(h2.id)""Select h1.id from table1 h1,table2 h2 where h1.id <>2.id)"both display Repetition of all values and gives me 'n' number of records.. cartesian productplz lemmme know how to do it?Thx in advance,Shan Quote Link to comment Share on other sites More sharing options...
shan_cool Posted August 9, 2006 Author Share Posted August 9, 2006 hi, I have tried that too. it displays the same numbaer of repeated records ony... any other way? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 9, 2006 Share Posted August 9, 2006 Try the following:[code]Select h1.id from table1 h1 left join table2 h2 on ( h1.id = h2.id) where h2.id is null[/code] Quote Link to comment Share on other sites More sharing options...
shan_cool Posted August 10, 2006 Author Share Posted August 10, 2006 Hi, Thanks Verymuch for ur reply.. The Query works fine..Rgds,Shan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.