Union or Union All

F

FSUrules2883

I am trying to combine two tables but when i get to a text field it
returns a null value. Is there any way to get the query to return how
I want it?
Table 1
Customer TEXT TEXT2
A1 A123 A345
C1 A234 A567
A1 A345 A678
A1 A456 A789

Table 2
Customer TEXT TEXT2
E1 B987 B654
F1 B876 B543
E1 B765 B432

What I want to be the returned value
Customer TEXT TEXT2
A1 A123 A345
C1 A234 A567
A1 A345 A678
A1 A456 A789
E1 B987 B654
F1 B876 B543
E1 B765 B432

What I get
Customer TEXT TEXT2
A1
C1
A1
A1
E1
F1
E1
 
M

Maurice

Try this:

SELECT Table1.Customer, Table1.text1, Table1.text2
FROM Table1
UNION SELECT Table2.Customer, Table2.text1, table2.text2
FROM Table2;


That should give you the result you are looking for. Remember that "Text" is
a reserved word so try changing that to "Text1"

hth
 
M

Marshall Barton

I am trying to combine two tables but when i get to a text field it
returns a null value. Is there any way to get the query to return how
I want it?
Table 1
Customer TEXT TEXT2
A1 A123 A345
C1 A234 A567
A1 A345 A678
A1 A456 A789

Table 2
Customer TEXT TEXT2
E1 B987 B654
F1 B876 B543
E1 B765 B432

What I want to be the returned value
Customer TEXT TEXT2
A1 A123 A345
C1 A234 A567
A1 A345 A678
A1 A456 A789
E1 B987 B654
F1 B876 B543
E1 B765 B432


SELECT Customer, TEXT, TEXT2 FROM table1
UNION ALL
SELECT Customer, TEXT, TEXT2 FROM table2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top