Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everyone,

I have one odd doubt in sql, the doubt is as described below:

I have two tables A and B, now i have one parameter which i want to check whether the value in the parameter is stored in either of table A or B in a single line query.. (i.e. not two queries for checking value in two tables) how can i achieve this?

Eg. Table A and B

Value = 5

to check whether 5 is present in A or in B or in Both...

Please help me out with it..

Thanks
Posted
Comments
Kornfeld Eliyahu Peter 16-Sep-14 4:33am    
Have you done anything so far? Please show some effort (search or code)! As is it ain't a question...

You define another user defined function where you can check above requirement and return a value.
Like 0 - Not exist in any table
1- Exist in Table A
2- Exist in Table B
3- Exist in both table.
Just call this UDF where needed.
 
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