I have the below sql query:
select @table1 as DataState, * from
(select * from importedcsvclients
except
select * from tblClients) x
union all
select @table2 as DataState, * from
(select * from tblClients
except select *
from importedcsvclients) x
The above code works fine, however, if table1 and table2 consist similar data, both records will show.
Can anyone assist me to make the query work as:
get the results of both table1 and table2, but only show table2 data if the same name doesn’t exist in table1.
Thanks.
For Info:
table1
ID Name
1 TestA
2 TestB
3 TestC
4 TestD
table2
ID Name
1 TestE
2 TestF
3 TestG
4 TestD
Results:
Name DataState
TestA table1
TestB table1
TestC table1
TestD table1
TestE table2
TestF table2
TestG table2
I used the below now.
Thanks for all assistance.