Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends
I want to get the data that does not exits in another table

eg. suppose i have two table A and B which contains
Table A Table B
srprefix srno prefix no
pp/10 1 pp/10 1
pp/10 2 pp/10 2
pp/10 3 pp/10 3
pp/09 3

pls help me how could i get the output which does not exits in Table A
checking both the prefix and no fields

i.e pp/09 3

i used join but it does not work properly

Thank u
Posted
Updated 9-Sep-10 0:47am
v3

The following query does the trick if the srno and no columns have the same content:

select * from B where no NOT IN (SELECT srno from A)
 
Share this answer
 
Comments
Sagar Khairnar 55 9-Sep-10 6:40am    
HI SIR,
thank u for giving me the solution but i want to check both the fields prefix and no.
Table A Table B
srprefix srno prefix no
pp/10 1 pp/10 1
pp/10 2 pp/10 2
pp/10 3
pp/09 3
i want the output as
pp/10 3
A quick solution for that would be:

select * from B where no+''+prefix NOT IN (SELECT srno+''+srprefix from A)


NOTE: I did not test this. So you might get some errors (and probably you can also remove the '' concatenation)
 
Share this answer
 
v2
Comments
Sagar Khairnar 55 9-Sep-10 6:52am    
No Sir ,
thats not working ,
i also tried

SELECT prefix,doc_no
FROM PCHALLAN
WHERE doc_no
NOT IN (SELECT chln_prefix+chln_no FROM PURBILL)
AND prefix NOT IN (SELECT chln_prefix FROM PURBILL)
but not working
pls help me
OK THE PROBLEM IS SOLVED

I USED EXCEPT KEYWORD

--TABLE PURCHASE CHALLAN
SELECT chln_prefix,chln_no
FROM PC
EXCEPT

--TABLE PURCHASE BILL
SELECT prefix,doc_no
FROM PB
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900