hi Programmers!
I have to compare the select query between union query
My code goes like this:
select emp_id,type from
(
select emp_id,'leave' as type
from tbl_emp_info
where emp_id like'5_2' or emp_id like '602'
) as t1
union
select emp_id,type from
(
select emp_id,'weekend'as type
from tbl_emp_off_info
where emp_id like'6_2'
) t2 t1.emp_id!=t2.emp_id
I need to compare these two select query
As i need the result like
EMP_ID TYPE
512 leave
612 weekend
But not like
EMP_ID TYPE
512 leave
612 leave
612 weekend
Please help me out
Perhaps this will work for you (SQL Server 2005 and up).
For SQL Server 2000 you’ll need to duplicate one of the WHERE clauses: