Click here to Skip to main content
15,891,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I have two tables with people id codes and their category code.
Id, codes are same for both tables.

Tables look like :
SQL
Table1 
-----------
id|Code                   
1|10                    
2|25                    
3|21                    
4|10                    
5|10


Table2
------------
id|Code
1|902
2|903
3|904
4|926
Posted
Comments
[no name] 9-Oct-15 4:07am    
From your example what is the result do you need?
Ankur_Garg 9-Oct-15 5:08am    
could you post the expected result?

 
Share this answer
 
hi check the fallowing code
---------------------------------------
create view viwename
as
select id,code from table1
union all
select id,code from table2
-------------------------------------------
create procedure duplicatechcking
(
@id int,@code int
)
begin
if exists(select id,code from viwename where id=@id and code=@code)
begin
select 1
end
else
begin
select 0
end
end
 
Share this answer
 
Comments
Андрей Голубцов 11-Nov-15 4:12am    
Thanks )

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