Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COMBINE TWO QUERIES INTO ONE TABLE

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
HOW CAN I TAKE THE FIELDS OF TWO QUERIES AND COMBINE THEM INTO ONE TABLE?

SOME OF THE FIELDS IN BOTH QUERIES HAVE THE SAME NAMES BUT I STILL WANT BOTH FIELDS TO SHOW UP IN THE TABLE. EXAMPLE

QUERY 1:
PART_NUMBE
DESCRIPTIO
QTY
TYPE
CSLTM

QUERY 2:
PART_NUMBE
DESCRIPTIO
QTY
TYPE
BSLTM

The only fields that do not have the same names are the CSLTM AND BSLTM. I want all the fields to be in one table:

Example:
PART_NUMBE
PART_NUMBE1
DESCRIPTIO
DESCRIPTIO1, ETC ETC.

Is there anyway to combine two queries into one table?

 
Please say that the answer given did not suit / work for you.
FIELDS FROM TWO TABLES
thread701-1195506
 
I viewed my other thread as separate thread. Now I am wanting to combine two queries and all their fields into one table. If you think these two threads are the same then the other one did not work for me but I appreciate your help.
 
Something like this ?
SELECT a.PART_NUMBE, b.PART_NUMBE, a.DESCRIPTIO, b.DESCRIPTIO, a.QTY, b.QTY, a.TYPE, b.TYPE, a.CSLTM, b.BSLTM
FROM Query1 a LEFT JOIN Query2 b ON a.PART_NUMBE = b.PART_NUMBE
UNION SELECT a.PART_NUMBE, b.PART_NUMBE, a.DESCRIPTIO, b.DESCRIPTIO, a.QTY, b.QTY, a.TYPE, b.TYPE, a.CSLTM, b.BSLTM
FROM Query1 a RIGHT JOIN Query2 b ON a.SOECODE = b.SOECODE
WHERE a.PART_NUMBE IS NULL

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top