0

i need all the data that in table1 + all the data that in table2

Except what in table2 that As it in table1

I do not know how to explain... so I will detail what i need using tables....

sample 1 ----------

Table1
=====
Name | Age
========
  M     |  1
  M     |  2
  M     |  1

Table2
=====
Name | Age
========
  M     |  1
  M     |  1
  M     |  1 


Result
====

Name | Age
========
  M     |  1
  M     |  2
  M     |  1 

sample2 ---------

Table1
=====
Name | Age
========
  M     |  1
  M     |  2
  M     |  1

Table2
=====
Name | Age
========
  M     |  1
  M     |  3
  M     |  2 


Result
====

Name | Age
========
  M     |  1
  M     |  1
  M     |  2 
  M     |  3

thanks

GoldSoft
  • 33
  • 1
  • 7
  • Are you also trying to match on a 'row number' per say? If so, how are you sorting the results? Do these tables have a primary key to join with, or sort by, a name, ID, anything? – Apothis Aug 25 '14 at 13:39

1 Answers1

0

I believe UNION is your best answer, though the way your question is asked, neither union nor union all will give the results you seek.

What is the difference between UNION and UNION ALL?

Community
  • 1
  • 1
Apothis
  • 406
  • 3
  • 7
  • `UNION` will in fact give what you are after is you have more data in the tables you are selecting from than given in the example, like a name or ID. Being that was not included in the question, this information would help to better answer your request. – Apothis Aug 25 '14 at 13:41